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
Push — bs4 ( 061bb9...0953c1 )
by
unknown
18s queued 13s
created

FormCard::addHeader()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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