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.
Passed
Push — merge-dev-to-master ( fdc6fe )
by
unknown
11:18
created

ActionsForm   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 148
Duplicated Lines 0 %

Importance

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

11 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 13 1
A getPlacement() 0 3 1
A __construct() 0 3 1
A clear() 0 5 1
A initialize() 0 11 2
A push() 0 5 1
A set() 0 13 3
A setView() 0 5 1
A getView() 0 3 1
A setPlacement() 0 5 1
A all() 0 3 1
1
<?php
2
3
namespace SleepingOwl\Admin\Display\Extension;
4
5
use Illuminate\Support\Collection;
6
use SleepingOwl\Admin\Form\FormElement;
7
use KodiComponents\Support\HtmlAttributes;
8
use SleepingOwl\Admin\Contracts\Initializable;
9
use SleepingOwl\Admin\Contracts\Display\Placable;
10
use SleepingOwl\Admin\Contracts\Display\Extension\ActionInterface;
11
12
class ActionsForm extends Extension implements Initializable, Placable
13
{
14
    use HtmlAttributes;
15
16
    /**
17
     * @var ActionInterface[]|Collection
18
     */
19
    protected $action_form;
20
21
    /**
22
     * @var string|\Illuminate\View\View
23
     */
24
    protected $view = 'display.extensions.actions_form';
25
26
    /**
27
     * @var string
28
     */
29
    protected $placement = 'panel.heading.actions';
30
31
    public function __construct()
32
    {
33
        $this->clear();
34
    }
35
36
    /**
37
     * @return $this
38
     */
39
    public function clear()
40
    {
41
        $this->action_form = new Collection();
42
43
        return $this;
44
    }
45
46
    /**
47
     * @param Collection|array $actions
48
     *
49
     * @return \SleepingOwl\Admin\Contracts\Display\DisplayInterface
50
     */
51
    public function set($action_form)
52
    {
53
        if (! is_array($action_form)) {
54
            $action_form = func_get_args();
55
        }
56
57
        $this->clear();
58
59
        foreach ($action_form as $action) {
60
            $this->push($action);
61
        }
62
63
        return $this->getDisplay();
64
    }
65
66
    /**
67
     * @return ActionInterface[]|Collection
68
     */
69
    public function all()
70
    {
71
        return $this->action_form;
72
    }
73
74
    /**
75
     * @param FormElement $action
76
     *
77
     * @return $this
78
     */
79
    public function push(FormElement $action)
80
    {
81
        $this->action_form->push($action);
82
83
        return $this;
84
    }
85
86
    /**
87
     * @return string|\Illuminate\View\View
88
     */
89
    public function getView()
90
    {
91
        return $this->view;
92
    }
93
94
    /**
95
     * @param string|\Illuminate\View\View $view
96
     *
97
     * @return $this
98
     */
99
    public function setView($view)
100
    {
101
        $this->view = $view;
102
103
        return $this;
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getPlacement()
110
    {
111
        return $this->placement;
112
    }
113
114
    /**
115
     * @param string $placement
116
     *
117
     * @return $this
118
     */
119
    public function setPlacement($placement)
120
    {
121
        $this->placement = $placement;
122
123
        return $this;
124
    }
125
126
    /**
127
     * Get the instance as an array.
128
     *
129
     * @return array
130
     */
131
    public function toArray()
132
    {
133
        $this->all()->each(function ($action) {
134
            $action->initialize();
135
        });
136
137
        $return = [
138
            'action_form' => $this->action_form,
139
            'placement' => $this->getPlacement(),
140
            'attributes' => $this->htmlAttributesToString(),
141
        ];
142
143
        return $return;
144
    }
145
146
    /**
147
     * Initialize class.
148
     */
149
    public function initialize()
150
    {
151
        if ($this->all()->count() < 1) {
152
            return;
153
        }
154
155
        $this->all()->each(function ($action) {
156
            $action->initialize();
157
        });
158
159
        $this->setHtmlAttribute('class', 'display-actions-form-wrapper');
160
    }
161
}
162