Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
2 / 4 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
| DiscoveredFiles | |
50.00% |
2 / 4 |
|
50.00% |
2 / 4 |
6.00 | |
0.00% |
0 / 1 |
| add | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getFiles | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sort | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BrianHenryIE\Strauss\Files; |
| 4 | |
| 5 | use BrianHenryIE\Strauss\Composer\ComposerPackage; |
| 6 | |
| 7 | class DiscoveredFiles |
| 8 | { |
| 9 | /** @var array<string,FileBase|File|FileWithDependency> */ |
| 10 | protected array $files = []; |
| 11 | |
| 12 | public function add(FileBase $file): void |
| 13 | { |
| 14 | $this->files[$file->getSourcePath()] = $file; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @return array<string,FileBase|File|FileWithDependency> |
| 19 | */ |
| 20 | public function getFiles(): array |
| 21 | { |
| 22 | return $this->files; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Fetch/check if a file exists in the discovered files. |
| 27 | * |
| 28 | * @param string $sourceAbsolutePath Full path to the file. |
| 29 | */ |
| 30 | public function getFile(string $sourceAbsolutePath): ?FileBase |
| 31 | { |
| 32 | return $this->files[$sourceAbsolutePath] ?? null; |
| 33 | } |
| 34 | |
| 35 | public function sort(): void |
| 36 | { |
| 37 | ksort($this->files); |
| 38 | } |
| 39 | } |