@@ 11-38 (lines=28) @@ | ||
8 | use UCD\Infrastructure\Repository\CharacterRepository\FileRepository\PropertyFileDirectory; |
|
9 | use UCD\Infrastructure\Repository\CharacterRepository\FileRepository\PropertyFiles; |
|
10 | ||
11 | class PHPPropertyFileDirectory extends PropertyFileDirectory |
|
12 | { |
|
13 | /** |
|
14 | * @param \SplFileInfo $basePath |
|
15 | * @return PHPPropertyFileDirectory |
|
16 | */ |
|
17 | public static function fromPath(\SplFileInfo $basePath) |
|
18 | { |
|
19 | $files = []; |
|
20 | $fileInfos = FileIterator::fromPath($basePath); |
|
21 | ||
22 | foreach ($fileInfos as $fileInfo) { |
|
23 | $file = PHPPropertyFile::fromFileInfo($fileInfo); |
|
24 | array_push($files, $file); |
|
25 | } |
|
26 | ||
27 | return new self($basePath, new PropertyFiles($files)); |
|
28 | } |
|
29 | ||
30 | /** |
|
31 | * @param Property $property |
|
32 | * @return PropertyFile |
|
33 | */ |
|
34 | protected function createFileForProperty(Property $property) |
|
35 | { |
|
36 | return PHPPropertyFile::fromProperty($this->basePath, $property); |
|
37 | } |
|
38 | } |
@@ 11-40 (lines=30) @@ | ||
8 | use UCD\Infrastructure\Repository\CharacterRepository\FileRepository\RangeFileDirectory; |
|
9 | use UCD\Infrastructure\Repository\CharacterRepository\FileRepository\RangeFiles; |
|
10 | ||
11 | class PHPRangeFileDirectory extends RangeFileDirectory |
|
12 | { |
|
13 | /** |
|
14 | * @param \SplFileInfo $basePath |
|
15 | * @return PHPRangeFileDirectory |
|
16 | * @throws \UCD\Exception\InvalidArgumentException |
|
17 | */ |
|
18 | public static function fromPath(\SplFileInfo $basePath) |
|
19 | { |
|
20 | $files = []; |
|
21 | $fileInfos = FileIterator::fromPath($basePath); |
|
22 | ||
23 | foreach ($fileInfos as $fileInfo) { |
|
24 | $file = PHPRangeFile::fromFileInfo($fileInfo); |
|
25 | array_push($files, $file); |
|
26 | } |
|
27 | ||
28 | return new self($basePath, new RangeFiles($files)); |
|
29 | } |
|
30 | ||
31 | /** |
|
32 | * @param Range $range |
|
33 | * @param int $total |
|
34 | * @return RangeFile |
|
35 | */ |
|
36 | protected function createFileFromRangeAndTotal(Range $range, $total) |
|
37 | { |
|
38 | return PHPRangeFile::fromRangeAndTotal($this->basePath, $range, $total); |
|
39 | } |
|
40 | } |