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 — development-bs4 ( bc8456...b9684a )
by butschster
29:24 queued 19:50
created

FormCard   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 36
dl 0
loc 123
rs 10
c 1
b 0
f 0
wmc 14

7 Methods

Rating   Name   Duplication   Size   Complexity  
A addFooter() 0 9 2
A addItem() 0 9 2
A addHeader() 0 9 2
A setItems() 0 9 2
A __construct() 0 5 1
A addBody() 0 14 4
A initialize() 0 7 1
1
<?php
2
3
namespace SleepingOwl\Admin\Form;
4
5
use SleepingOwl\Admin\Form\Card\Body;
6
use SleepingOwl\Admin\Form\Card\Footer;
7
use SleepingOwl\Admin\Form\Card\Header;
8
use SleepingOwl\Admin\Form\Element\Html;
9
use SleepingOwl\Admin\Traits\CardControl;
10
use SleepingOwl\Admin\Contracts\Form\FormElementInterface;
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
            $items = func_get_args();
61
        }
62
63
        $this->addBody($items);
64
65
        return $this;
66
    }
67
68
    /**
69
     * @param FormElementInterface $item
70
     *
71
     * @return $this
72
     */
73
    public function addItem($item)
74
    {
75
        if ($part = $this->getElements()->last()) {
76
            $part->addElement($item);
77
        } else {
78
            $this->addBody($item);
79
        }
80
81
        return $this;
82
    }
83
84
    /**
85
     * @param array|FormElementInterface $items
86
     *
87
     * @return $this
88
     */
89
    public function addHeader($items)
90
    {
91
        if (! is_array($items)) {
92
            $items = func_get_args();
93
        }
94
95
        $this->addElement(new Header($items));
96
97
        return $this;
98
    }
99
100
    /**
101
     * @param array|FormElementInterface $items
102
     *
103
     * @return $this
104
     */
105
    public function addBody($items)
106
    {
107
        if (! is_array($items)) {
108
            $items = func_get_args();
109
        }
110
111
        $class = $this->getElements()->last();
112
        if (is_object($class) && get_class($class) === Body::class) {
113
            $this->addElement(new Html('<hr />'));
114
        }
115
116
        $this->addElement(new Body($items));
117
118
        return $this;
119
    }
120
121
    /**
122
     * @param array|FormElementInterface $items
123
     *
124
     * @return $this
125
     */
126
    public function addFooter($items)
127
    {
128
        if (! is_array($items)) {
129
            $items = func_get_args();
130
        }
131
132
        $this->addElement(new Footer($items));
133
134
        return $this;
135
    }
136
}
137