Html::activeFieldAddon()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace thoulah\fontawesome\bootstrap4;
4
5
/**
6
 * {@inheritdoc}
7
 */
8
class Html extends \yii\bootstrap4\Html
9
{
10
    /**
11
     * Returns the ActiveField inputTemplate.
12
     *
13
     * @param string|null $groupSize Size of the `input-group`
14
     * @param bool|null   $append    Whether to prepend or append the `input-group`
15
     *
16
     * @return string
17
     */
18
    public static function activeFieldAddon(?string $groupSize, ?bool $append): string
19
    {
20
        $inputGroupClass = ['input-group'];
21
        if (null !== $groupSize && 'md' !== $groupSize) {
22
            static::addCssClass($inputGroupClass, "input-group-{$groupSize}");
23
        }
24
25
        return static::tag('div', ($append) ? '{input}{icon}' : '{icon}{input}', ['class' => $inputGroupClass]);
26
    }
27
28
    /**
29
     * Returns the ActiveField Icon.
30
     *
31
     * @param bool|null $append Whether to prepend or append the `input-group`
32
     *
33
     * @return
34
     */
35
    public static function activeFieldIcon(?bool $append): string
36
    {
37
        $direction = ($append) ? 'append' : 'prepend';
38
        $icon = static::tag('div', '{icon}', ['class' => 'input-group-text']);
39
40
        return static::tag('div', $icon, ['class' => "input-group-{$direction}"]);
41
    }
42
}
43