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

Checkbox::getDefaultValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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