Completed
Push — master ( d98c10...e4052f )
by Nikolas
04:37
created

ActionList::getGroups()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace rtens\domin\delivery\web\home;
3
4
5
use rtens\domin\delivery\web\ActionGroups;
6
7
class ActionList {
8
9
    /** @var array|ActionListItem[] */
10
    private $actions;
11
12
    /** @var ActionGroups */
13
    private $groups;
14
15
    /**
16
     * @param ActionGroups $groups
17
     * @param ActionListItem[] $actions
18
     */
19
    public function __construct(ActionGroups $groups, array $actions) {
20
        $this->actions = $actions;
21
        $this->groups = $groups;
22
    }
23
24
    public function hasGroups() {
25
        return count($this->groups->getGroups()) != 0;
26
    }
27
28
    public function getAllActions() {
29
        return $this->actions;
30
    }
31
32
    public function getGroups() {
33
        return $this->groups->getGroups();
34
    }
35
36
    public function getActionsOf($group) {
37
        $actions = array_keys($this->groups->getActionsOf($group));
38
        return array_filter($this->actions, function (ActionListItem $action) use ($actions) {
39
            return in_array($action->getId(), $actions);
40
        });
41
    }
42
}