These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Helper\AdminPanel; |
||
4 | |||
5 | class AdminPanel |
||
6 | { |
||
7 | /** |
||
8 | * @var AdminPanelAdaptorInterface[] |
||
9 | */ |
||
10 | private $adaptors = []; |
||
11 | |||
12 | /** |
||
13 | * @var AdminPanelAdaptorInterface[] |
||
14 | */ |
||
15 | private $sorted = []; |
||
16 | |||
17 | /** |
||
18 | * @var AdminPanelActionInterface[] |
||
19 | */ |
||
20 | private $actions = null; |
||
21 | |||
22 | /** |
||
23 | * Add admin panel adaptor |
||
24 | */ |
||
25 | 1 | public function addAdminPanelAdaptor(AdminPanelAdaptorInterface $adaptor, $priority = 0) |
|
26 | { |
||
27 | 1 | $this->adaptors[$priority][] = $adaptor; |
|
28 | 1 | unset($this->sorted); |
|
29 | 1 | } |
|
30 | |||
31 | /** |
||
32 | * Return current admin panel actions |
||
33 | */ |
||
34 | 1 | public function getAdminPanelActions() |
|
35 | { |
||
36 | 1 | if (!$this->actions) { |
|
37 | 1 | $this->actions = []; |
|
38 | 1 | $adaptors = $this->getAdaptors(); |
|
39 | 1 | foreach ($adaptors as $adaptor) { |
|
40 | 1 | $this->actions = array_merge($this->actions, $adaptor->getAdminPanelActions()); |
|
41 | } |
||
42 | } |
||
43 | |||
44 | 1 | return $this->actions; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get adaptors sorted by priority. |
||
49 | * |
||
50 | * @return \Kunstmaan\AdminBundle\Helper\AdminPanel\AdminPanelAdaptorInterface[] |
||
0 ignored issues
–
show
|
|||
51 | */ |
||
52 | 1 | private function getAdaptors() |
|
53 | { |
||
54 | 1 | if (!isset($this->sorted)) { |
|
55 | 1 | $this->sortAdaptors(); |
|
56 | } |
||
57 | |||
58 | 1 | return $this->sorted; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * Sorts the internal list of adaptors by priority. |
||
63 | */ |
||
64 | 1 | View Code Duplication | private function sortAdaptors() |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
65 | { |
||
66 | 1 | $this->sorted = []; |
|
67 | |||
68 | 1 | if (isset($this->adaptors)) { |
|
69 | 1 | krsort($this->adaptors); |
|
70 | 1 | $this->sorted = array_merge(...$this->adaptors); |
|
71 | } |
||
72 | 1 | } |
|
73 | } |
||
74 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.