Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ValidatesExistence
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 validateExistence
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Hyde\Framework\Concerns;
6
7use Hyde\Facades\Filesystem;
8use Hyde\Framework\Exceptions\FileNotFoundException;
9
10/**
11 * Validate the existence of a Page class's source file.
12 */
13trait ValidatesExistence
14{
15    /**
16     * Check if a supplied source file exists or throw an exception.
17     *
18     * @param  class-string<\Hyde\Pages\Concerns\HydePage>  $pageClass
19     *
20     * @throws FileNotFoundException If the file does not exist.
21     */
22    protected static function validateExistence(string $pageClass, string $identifier): void
23    {
24        $path = $pageClass::sourcePath($identifier);
25
26        if (Filesystem::missing($path)) {
27            throw new FileNotFoundException($path);
28        }
29    }
30}