Checkbox   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 15 3
A __construct() 0 6 2
1
<?php
2
3
namespace GeminiLabs\Castor\Forms\Fields;
4
5
class Checkbox extends Base
6
{
7
    protected $element = 'input';
8
9
    public function __construct(array $args = [])
10
    {
11
        parent::__construct($args);
12
13
        if (count($args['options']) > 1) {
14
            $this->multi = true;
15
        }
16
    }
17
18
    /**
19
     * @return string
20
     */
21
    public function render()
22
    {
23
        $inline = $this->args['inline'] ? ' class="inline"' : '';
24
25
        if ($this->multi) {
26
            return sprintf('<ul%s>%s</ul>%s',
27
                $inline,
28
                $this->implodeOptions('multi_input_checkbox'),
29
                $this->generateDescription()
30
            );
31
        }
32
33
        return sprintf('%s%s',
34
            $this->implodeOptions('single_input'),
35
            $this->generateDescription()
36
        );
37
    }
38
}
39