Completed
Push — master ( f2fcb0...d4b67c )
by Song
03:48 queued 51s
created

CascadeGroup::dependsOn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
use Encore\Admin\Form\Field;
6
7
class CascadeGroup extends Field
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $dependency;
13
14
    /**
15
     * @var string
16
     */
17
    protected $hide = 'hide';
18
19
    /**
20
     * CascadeGroup constructor.
21
     *
22
     * @param array $dependency
23
     */
24
    public function __construct(array $dependency)
25
    {
26
        $this->dependency = $dependency;
27
    }
28
29
    /**
30
     * @param Field $field
31
     * @return bool
32
     */
33
    public function dependsOn(Field $field)
34
    {
35
        return $this->dependency['column'] == $field->column();
36
    }
37
38
    /**
39
     * @return integer
40
     */
41
    public function index()
42
    {
43
        return $this->dependency['index'];
44
    }
45
46
    /**
47
     * @return void
48
     */
49
    public function visiable()
50
    {
51
        $this->hide = '';
52
    }
53
54
    /**
55
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
56
     */
57
    public function render()
58
    {
59
        return <<<HTML
60
<div class="cascade-group {$this->dependency['class']} {$this->hide}">
61
HTML;
62
    }
63
64
    /**
65
     * @return void
66
     */
67
    public function end()
68
    {
69
        $this->form->html('</div>')->plain();
70
    }
71
}
72