Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
90.00% |
9 / 10 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| RootFolder | |
90.00% |
9 / 10 |
|
75.00% |
3 / 4 |
6.04 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getChild | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| getChildren | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\ApieFileSystem\Virtual; |
| 3 | |
| 4 | use Apie\ApieFileSystem\Lists\VirtualFileMap; |
| 5 | use Apie\Common\ActionDefinitionProvider; |
| 6 | use Apie\Core\BoundedContext\BoundedContextHashmap; |
| 7 | use Apie\Core\Context\ApieContext; |
| 8 | |
| 9 | /** |
| 10 | * Root folder of the virtual file system. |
| 11 | * This folder contains all bounded contexts as subfolders. |
| 12 | * |
| 13 | * @see BoundedContextFolder child folders |
| 14 | */ |
| 15 | class RootFolder implements VirtualFolderInterface |
| 16 | { |
| 17 | public function __construct( |
| 18 | private readonly BoundedContextHashmap $boundedContextHashmap, |
| 19 | private readonly ActionDefinitionProvider $actionDefinitionProvider, |
| 20 | private readonly ApieContext $apieContext |
| 21 | ) { |
| 22 | } |
| 23 | |
| 24 | public function getName(): string |
| 25 | { |
| 26 | return 'public'; |
| 27 | } |
| 28 | |
| 29 | public function getChild(string $name): VirtualFileInterface|VirtualFolderInterface|null |
| 30 | { |
| 31 | $boundedContext = $this->boundedContextHashmap[$name] ?? null; |
| 32 | if ($boundedContext !== null) { |
| 33 | return new BoundedContextFolder($boundedContext, $this->actionDefinitionProvider, $this->apieContext); |
| 34 | } |
| 35 | return null; |
| 36 | } |
| 37 | |
| 38 | public function getChildren(): VirtualFileMap |
| 39 | { |
| 40 | $folders = []; |
| 41 | foreach ($this->boundedContextHashmap as $name => $boundedContext) { |
| 42 | $folders[$name] = new BoundedContextFolder($boundedContext, $this->actionDefinitionProvider, $this->apieContext); |
| 43 | } |
| 44 | return new VirtualFileMap($folders); |
| 45 | } |
| 46 | } |