Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| AbstractPage | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| getCurrentPagePath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| all | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Hyde\Framework\Contracts; |
| 4 | |
| 5 | use Hyde\Framework\Concerns\HasPageMetadata; |
| 6 | use Hyde\Framework\Services\CollectionService; |
| 7 | use Illuminate\Support\Collection; |
| 8 | |
| 9 | /** |
| 10 | * To ensure compatability with the Hyde Framework, |
| 11 | * all Page Models must extend this class. |
| 12 | * |
| 13 | * Markdown-based Pages should extend MarkdownDocument. |
| 14 | */ |
| 15 | abstract class AbstractPage implements PageContract |
| 16 | { |
| 17 | use HasPageMetadata; |
| 18 | |
| 19 | public static string $sourceDirectory; |
| 20 | public static string $fileExtension; |
| 21 | public static string $parserClass; |
| 22 | |
| 23 | public string $slug; |
| 24 | |
| 25 | public function getCurrentPagePath(): string |
| 26 | { |
| 27 | return $this->slug; |
| 28 | } |
| 29 | |
| 30 | public static function all(): Collection |
| 31 | { |
| 32 | $collection = new Collection(); |
| 33 | |
| 34 | foreach (CollectionService::getSourceFileListForModel(static::class) as $filepath) { |
| 35 | $collection->push((new static::$parserClass(basename($filepath, static::$fileExtension)))->get()); |
| 36 | } |
| 37 | |
| 38 | return $collection; |
| 39 | } |
| 40 | } |