Passed
Pull Request — master (#6127)
by Angel Fernando Quiroz
07:51
created

AdminBlockHookEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setItems() 0 7 1
A getItems() 0 3 1
A getBlockNames() 0 3 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\HookEvent;
8
9
class AdminBlockHookEvent extends HookEvent
10
{
11
    /**
12
     * @return array<int, array<string, string>>
13
     */
14
    public function getItems(string $title): array
15
    {
16
        return $this->data[$title]['items'] ?? [];
17
    }
18
19
    public function setItems(string $title, array $items): static
20
    {
21
        $currentItems = $this->data[$title]['items'] ?? [];
22
23
        $this->data[$title]['items'] = [...$currentItems, ...$items];
24
25
        return $this;
26
    }
27
28
    /**
29
     * @return array<int, string>
30
     */
31
    public function getBlockNames(): array
32
    {
33
        return array_keys($this->data);
34
    }
35
}
36