Completed
Push — master ( 534ed1...5a2681 )
by wen
15:08
created

Checkbox   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 48
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getMax() 0 4 1
A setMax() 0 8 1
A getMin() 0 4 1
A setMin() 0 8 1
A getDefaultValue() 0 4 1
A toArray() 0 7 1
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
class Checkbox extends Select
6
{
7
    protected $type = 'checkbox';
8
9
    protected $max;
10
    protected $min = 0;
11
12
    public function getMax()
13
    {
14
        return $this->max;
15
    }
16
17
    public function setMax($value)
18
    {
19
        $this->max = (int)$value;
20
21
        $this->addValidationRule('max:' . $value);
22
23
        return $this;
24
    }
25
26
    public function getMin()
27
    {
28
        return $this->min;
29
    }
30
31
    public function setMin($value)
32
    {
33
        $this->min = (int)$value;
34
35
        $this->addValidationRule('min:' . $value);
36
37
        return $this;
38
    }
39
40
    protected function getDefaultValue()
41
    {
42
        return [];
43
    }
44
45
    public function toArray()
46
    {
47
        return parent::toArray() + [
48
                'min' => $this->getMin(),
49
                'max' => $this->getMax(),
50
            ];
51
    }
52
}
53