| Total Complexity | 13 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class SortedGenericList extends GenericList |
||
| 15 | { |
||
| 16 | 5 | public function sort(callable $callback): void |
|
| 17 | { |
||
| 18 | 5 | usort($this->elements, $callback); |
|
| 19 | 5 | } |
|
| 20 | |||
| 21 | /** @return mixed */ |
||
| 22 | 10 | public function atIndex(int $index) |
|
| 29 | } |
||
| 30 | |||
| 31 | /** @return mixed|null */ |
||
| 32 | 8 | public function atIndexOrNull(int $index) |
|
| 33 | { |
||
| 34 | 8 | if ($index < 0 || $index > $this->count() - 1) { |
|
| 35 | 3 | return null; |
|
| 36 | } |
||
| 37 | |||
| 38 | 5 | return $this->elements[$index]; |
|
| 39 | } |
||
| 40 | |||
| 41 | /** @return mixed */ |
||
| 42 | 3 | public function first() |
|
| 49 | } |
||
| 50 | |||
| 51 | /** @return mixed|null */ |
||
| 52 | 2 | public function firstOrNull() |
|
| 53 | { |
||
| 54 | 2 | return $this->atIndexOrNull(0); |
|
| 55 | } |
||
| 56 | |||
| 57 | /** @return mixed */ |
||
| 58 | 3 | public function last() |
|
| 65 | } |
||
| 66 | |||
| 67 | /** @return mixed|null */ |
||
| 68 | 2 | public function lastOrNull() |
|
| 71 | } |
||
| 72 | } |
||
| 73 |