Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
TreeDefinitions | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
makeDefinitions | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace pvc\struct\tree\di; |
6 | |
7 | use League\Container\Definition\Definition; |
8 | use League\Container\Definition\DefinitionInterface; |
9 | use pvc\interfaces\struct\payload\HasPayloadInterface; |
10 | use pvc\interfaces\validator\ValTesterInterface; |
11 | use pvc\struct\collection\Collection; |
12 | use pvc\struct\collection\CollectionFactory; |
13 | use pvc\struct\collection\CollectionIndexed; |
14 | use pvc\struct\collection\CollectionIndexedFactory; |
15 | use pvc\struct\tree\node\TreenodeFactory; |
16 | use pvc\struct\tree\tree\Tree; |
17 | use pvc\struct\tree\tree\TreeOrdered; |
18 | |
19 | /** |
20 | * @template PayloadType of HasPayloadInterface |
21 | */ |
22 | class TreeDefinitions |
23 | { |
24 | /** |
25 | * @return array<int, DefinitionInterface> |
26 | */ |
27 | public static function makeDefinitions(): array |
28 | { |
29 | return [ |
30 | |
31 | /** |
32 | * objects necessary to make a plain (unordered) tree |
33 | */ |
34 | (new Definition(Collection::class)), |
35 | (new Definition(CollectionFactory::class)), |
36 | (new Definition( 'TreenodeFactoryUnordered', TreenodeFactory::class)) |
37 | ->addArgument(CollectionFactory::class), |
38 | (new Definition(Tree::class))->addArgument('TreenodeFactoryUnordered'), |
39 | |
40 | /** |
41 | * objects necessary to make an ordered tree |
42 | */ |
43 | (new Definition(CollectionIndexed::class)), |
44 | (new Definition(CollectionIndexedFactory::class)), |
45 | (new Definition('TreenodeFactoryOrdered', TreenodeFactory::class)) |
46 | ->addArgument(CollectionIndexedFactory::class), |
47 | (new Definition(TreeOrdered::class))->addArgument('TreenodeFactoryOrdered'), |
48 | ]; |
49 | } |
50 | } |