Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 878079a

Browse files
committed
Minor code cleanup
The section was somewhat difficult to understand due to nested conditionals. Modified the workflow to reduce conditionals and transient variables.
1 parent ef6c009 commit 878079a

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/Factory.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -329,29 +329,28 @@ public function createInputFilter($inputFilterSpecification)
329329
if (($value instanceof InputInterface)
330330
|| ($value instanceof InputFilterInterface)
331331
) {
332-
$input = $value;
333-
} else {
334-
335-
// Patch to enable nested, integer indexed input_filter_specs
336-
// Check type and name are in spec
337-
if (isset($value['type']) && is_string($value['type'])
338-
&& isset($value['name']) && is_string($value['name'])) {
339-
// Make sure type is an InputFilter
340-
$checkType = $this->getInputFilterManager()->get($value['type']);
341-
if ($checkType instanceof InputFilter) {
342-
// Only apply when key is an integer
343-
if (is_integer($key)) {
344-
$key = $value['name'];
345-
}
346-
// Remove name from spec. InputFilter doesn't have an name property!
347-
unset($value['name']);
348-
}
332+
$inputFilter->add($value, $key);
333+
continue;
334+
}
335+
336+
// Patch to enable nested, integer indexed input_filter_specs.
337+
// Check type and name are in spec, and that composed type is
338+
// an input filter...
339+
if ((isset($value['type']) && is_string($value['type']))
340+
&& (isset($value['name']) && is_string($value['name']))
341+
&& $this->getInputFilterManager()->get($value['type']) instanceof InputFilter
342+
) {
343+
// If $key is an integer, reset it to the specified name.
344+
if (is_integer($key)) {
345+
$key = $value['name'];
349346
}
350347

351-
$input = $this->createInput($value);
348+
// Remove name from specification. InputFilter doesn't have a
349+
// name property!
350+
unset($value['name']);
352351
}
353352

354-
$inputFilter->add($input, $key);
353+
$inputFilter->add($this->createInput($value), $key);
355354
}
356355

357356
return $inputFilter;

0 commit comments

Comments
 (0)