1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace PHPStan\BetterReflection\SourceLocator;
6:
7: use PHPStan\BetterReflection\SourceLocator\Exception\InvalidFileLocation;
8:
9: use function is_file;
10: use function is_readable;
11: use function sprintf;
12:
13: class FileChecker
14: {
15: /**
16: * @param non-empty-string $filename
17: *
18: * @throws InvalidFileLocation
19: */
20: public static function assertReadableFile(string $filename): void
21: {
22: if (! is_file($filename)) {
23: throw new InvalidFileLocation(sprintf('"%s" is not a file', $filename));
24: }
25:
26: if (! is_readable($filename)) {
27: throw new InvalidFileLocation(sprintf('File "%s" is not readable', $filename));
28: }
29: }
30: }
31: