Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| AbstractCollection | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromArray | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromMap | |
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; |
| 11 | |
| 12 | use ArrayAccess; |
| 13 | use Override; |
| 14 | use Phexium\Domain\Collection\Trait\TraitArrayAccess; |
| 15 | use Phexium\Domain\Collection\Trait\TraitCollectionCore; |
| 16 | use Phexium\Domain\Collection\Trait\TraitCollectionFunctional; |
| 17 | use Phexium\Domain\Collection\Trait\TraitCollectionMutation; |
| 18 | use Phexium\Domain\Collection\Trait\TraitCollectionNavigation; |
| 19 | use Phexium\Domain\Collection\Trait\TraitCollectionSearch; |
| 20 | use Phexium\Domain\Collection\Trait\TraitCollectionTransformation; |
| 21 | |
| 22 | abstract class AbstractCollection implements CollectionInterface, ArrayAccess |
| 23 | { |
| 24 | use TraitArrayAccess; |
| 25 | use TraitCollectionCore; |
| 26 | use TraitCollectionFunctional; |
| 27 | use TraitCollectionMutation; |
| 28 | use TraitCollectionNavigation; |
| 29 | use TraitCollectionSearch; |
| 30 | use TraitCollectionTransformation; |
| 31 | |
| 32 | protected array $collection = []; |
| 33 | |
| 34 | public function __construct(array $collection = []) |
| 35 | { |
| 36 | $this->collection = $collection; |
| 37 | } |
| 38 | |
| 39 | #[Override] |
| 40 | public static function fromArray(array $collection): static |
| 41 | { |
| 42 | return new static($collection); |
| 43 | } |
| 44 | |
| 45 | #[Override] |
| 46 | public static function fromMap(array $collection, callable $fn): static |
| 47 | { |
| 48 | return new static(array_map($fn, $collection)); |
| 49 | } |
| 50 | } |