Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| TraitCollectionNavigation | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| keys | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| containsKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace Phexium\Domain\Collection\Trait; |
| 11 | |
| 12 | trait TraitCollectionNavigation |
| 13 | { |
| 14 | public function keys(): array |
| 15 | { |
| 16 | return array_keys($this->collection); |
| 17 | } |
| 18 | |
| 19 | public function containsKey(int|string $key): bool |
| 20 | { |
| 21 | return array_key_exists($key, $this->collection); |
| 22 | } |
| 23 | |
| 24 | public function get(int|string $key, mixed $default = null): mixed |
| 25 | { |
| 26 | return $this->collection[$key] ?? $default; |
| 27 | } |
| 28 | } |