| Total Complexity | 7 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class ViewDiffService |
||
| 13 | { |
||
| 14 | public static function getFilecache(): array |
||
| 15 | { |
||
| 16 | $filecache = []; |
||
| 17 | |||
| 18 | $files = glob(Hyde::vendorPath('resources/views/**/*.blade.php')); |
||
| 19 | |||
| 20 | foreach ($files as $file) { |
||
| 21 | $filecache[str_replace(Hyde::vendorPath(), '', $file)] = [ |
||
| 22 | 'unixsum' => static::unixsumFile($file), |
||
| 23 | ]; |
||
| 24 | } |
||
| 25 | |||
| 26 | return $filecache; |
||
| 27 | } |
||
| 28 | |||
| 29 | public static function getChecksums(): array |
||
| 30 | { |
||
| 31 | $cache = static::getFilecache(); |
||
| 32 | |||
| 33 | $checksums = []; |
||
| 34 | |||
| 35 | foreach ($cache as $file) { |
||
| 36 | $checksums[] = $file['unixsum']; |
||
| 37 | } |
||
| 38 | |||
| 39 | return $checksums; |
||
| 40 | } |
||
| 41 | |||
| 42 | public static function checksumMatchesAny(string $checksum): bool |
||
| 43 | { |
||
| 44 | return in_array($checksum, static::getChecksums()); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * A EOL agnostic wrapper for calculating MD5 checksums. |
||
| 49 | * |
||
| 50 | * @internal This function is not cryptographically secure. |
||
| 51 | * |
||
| 52 | * @see https://github.com/hydephp/framework/issues/85 |
||
| 53 | */ |
||
| 54 | public static function unixsum(string $string): string |
||
| 59 | } |
||
| 60 | |||
| 61 | /* Shorthand for @see static::unixsum() but loads a file */ |
||
| 62 | public static function unixsumFile(string $file): string |
||
| 65 | } |
||
| 66 | } |
||
| 67 |