Completed
Push — master ( 545216...bb1888 )
by wen
14:38
created

Checkbox   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

7 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 isShowCheckAll() 0 4 1
A enableShowCheckAll() 0 6 1
A toArray() 0 8 1
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
use Illuminate\Support\Collection;
6
7
/**
8
 * Checkbox
9
 *
10
 * @see http://element.eleme.io/#/zh-CN/component/checkbox
11
 */
12
class Checkbox extends MultiSelect
13
{
14
    protected $type = 'checkbox';
15
16
    protected $defaultValue = [];
17
18
    protected $max;
19
    protected $min          = 0;
20
    protected $showCheckAll = false;
21
22
    public function getMax()
23
    {
24
        return $this->max;
25
    }
26
27
    public function setMax($value)
28
    {
29
        $this->max = (int)$value;
30
31
        $this->addValidationRule('max:' . $value);
32
33
        return $this;
34
    }
35
36
    public function getMin()
37
    {
38
        return $this->min;
39
    }
40
41
    public function setMin($value)
42
    {
43
        $this->min = (int)$value;
44
45
        $this->addValidationRule('min:' . $value);
46
47
        return $this;
48
    }
49
50
    public function isShowCheckAll()
51
    {
52
        return $this->showCheckAll;
53
    }
54
55
    public function enableShowCheckAll()
56
    {
57
        $this->showCheckAll = true;
58
59
        return $this;
60
    }
61
62
    public function toArray()
63
    {
64
        return parent::toArray() + [
65
                'min'          => $this->getMin(),
66
                'max'          => $this->getMax(),
67
                'showCheckAll' => $this->isShowCheckAll(),
68
            ];
69
    }
70
}
71