Total Complexity | 6 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | trait ListAccessTrait |
||
17 | { |
||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | 6 | public function get(int $index) |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param int $index |
||
28 | * @param mixed $element |
||
29 | * @return void |
||
30 | */ |
||
31 | 1 | public function set(int $index, $element): void |
|
32 | { |
||
33 | 1 | $this->array[$index] = $element; |
|
34 | 1 | } |
|
35 | |||
36 | /** |
||
37 | * @inheritDoc |
||
38 | */ |
||
39 | 2 | public function first() |
|
40 | { |
||
41 | 2 | if (empty($this->array)) { |
|
42 | 1 | return null; |
|
43 | } |
||
44 | 1 | reset($this->array); |
|
45 | 1 | return $this->array[key($this->array)]; |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @inheritDoc |
||
50 | */ |
||
51 | 3 | public function last() |
|
56 | } |
||
57 | } |
||
58 |