Completed
Push — master ( 60ac2f...695cd7 )
by Denis
01:32
created

BaseCheckedElement   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A checked() 0 4 2
A beforeElementPrepareToRender() 0 4 1
1
<?php
2
3
namespace Ngtfkx\Laradeck\FormBuilder\Elements;
4
5
6
abstract class BaseCheckedElement extends AbstractElement
7
{
8
    public $checked = false;
9
10
    public function __construct(?string $name = null, ?string $value = '1', ?bool $state = false)
11
    {
12
        parent::__construct();
13
14
        $this->name($name);
15
16
        $this->value($value);
17
18
        $this->checked($state);
19
    }
20
21
    public function checked(?bool $state = true)
22
    {
23
        $this->checked = $state ?: false;
24
    }
25
26
    public function beforeElementPrepareToRender(): void
27
    {
28
        $this->addAttrAs('checked');
29
    }
30
}