GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#971)
by Dave
22:56 queued 17:27
created

FormPanel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SleepingOwl\Admin\Form;
4
5
use SleepingOwl\Admin\Form\Panel\Body;
6
use SleepingOwl\Admin\Form\Element\Html;
7
use SleepingOwl\Admin\Form\Panel\Footer;
8
use SleepingOwl\Admin\Form\Panel\Header;
9
use SleepingOwl\Admin\Traits\PanelControl;
10
use SleepingOwl\Admin\Contracts\Form\FormElementInterface;
11
12
class FormPanel extends FormDefault
13
{
14
    use PanelControl;
15
16
    const POSITION_HEADER = 'header';
17
    const POSITION_BODY = 'body';
18
    const POSITION_FOOTER = 'footer';
19
20
    const SEPARATOR = '<hr class="panel-wide" />';
21
22
    /**
23
     * @var string
24
     */
25
    protected $view = 'form.panel';
26
27
    /**
28
     * FormPanel constructor.
29
     *
30
     * @param array $elements
31
     */
32
    public function __construct(array $elements = [])
33
    {
34
        parent::__construct($elements);
35
36
        $this->setPanelClass('panel-form');
37
    }
38
39
    /**
40
     * Initialize form.
41
     */
42
    public function initialize()
43
    {
44
        $this->getButtons()->setHtmlAttribute('class', 'panel-footer');
45
46
        $this->setHtmlAttribute('class', 'panel panel-default '.$this->getPanelClass());
47
48
        parent::initialize();
49
    }
50
51
    /**
52
     * @param array|FormElementInterface $items
53
     *
54
     * @return $this
55
     */
56
    public function setItems($items)
57
    {
58
        if (! is_array($items)) {
59
            $items = func_get_args();
60
        }
61
62
        $this->addBody($items);
63
64
        return $this;
65
    }
66
67
    /**
68
     * @param FormElementInterface $item
69
     *
70
     * @return $this
71
     */
72
    public function addItem($item)
73
    {
74
        if ($part = $this->getElements()->last()) {
75
            $part->addElement($item);
76
        } else {
77
            $this->addBody($item);
78
        }
79
80
        return $this;
81
    }
82
83
    /**
84
     * @param array|FormElementInterface $items
85
     *
86
     * @return $this
87
     */
88
    public function addHeader($items)
89
    {
90
        if (! is_array($items)) {
91
            $items = func_get_args();
92
        }
93
94
        $this->addElement(new Header($items));
95
96
        return $this;
97
    }
98
99
    /**
100
     * @param array|FormElementInterface $items
101
     *
102
     * @return $this
103
     */
104
    public function addBody($items)
105
    {
106
        if (! is_array($items)) {
107
            $items = func_get_args();
108
        }
109
110
        $class = $this->getElements()->last();
111
        if (is_object($class) && get_class($class) === Body::class) {
112
            $this->addElement(new Html('<hr />'));
113
        }
114
115
        $this->addElement(new Body($items));
116
117
        return $this;
118
    }
119
120
    /**
121
     * @param array|FormElementInterface $items
122
     *
123
     * @return $this
124
     */
125
    public function addFooter($items)
126
    {
127
        if (! is_array($items)) {
128
            $items = func_get_args();
129
        }
130
131
        $this->addElement(new Footer($items));
132
133
        return $this;
134
    }
135
}
136