Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

View/Front/default/_core/form/fieldset/radio.php (1 issue)

1
<?php
2
3
use Ffcms\Templex\Helper\Html\Dom;
4
5
/** @var \Ffcms\Templex\Template\Template $this */
6
7
// input type=radio
8
9
/** @var string $label */
10
/** @var array $properties */
11
/** @var string|null $helper */
12
/** @var array|null $labelProperties */
13
/** @var \Ffcms\Templex\Helper\Html\Form\Field\Radio $field */
14
15
if (!isset($labelProperties['class'])) {
16
    $labelProperties['class'] = 'col-md-3 control-label col-form-label';
17
}
18
19
if (!isset($properties['class'])) {
20
    $properties['class'] = 'form-check-input';
21
}
22
$properties['arrayLabelProperties']['class'] = 'form-check-label';
23
24
$inputs = $field->asArray($properties);
25
if (!$inputs || !is_array($inputs)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $inputs of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
26
    return null;
27
}
28
?>
29
<div class="form-group row">
30
    <?= (new \Ffcms\Templex\Helper\Html\Dom())->label(function() use ($label) {
31
        return $label;
32
    }, $labelProperties) ?>
33
    <div class="col-md-9">
34
        <?php
35
        foreach ($inputs as $input) {
36
            if (!is_string($input) || strlen($input) < 1) {
37
                continue;
38
            }
39
            echo (new Dom())->div(function() use ($input) {
40
                return $input;
41
            }, ['class' => 'form-check form-check-inline']);
42
        }
43
        ?>
44
        <?php if ($helper): ?>
45
            <p class="form-text"><?= $helper ?></p>
46
        <?php endif; ?>
47
    </div>
48
</div>