1 | <?php |
||
17 | class Builder |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * SHA256 Hash Algorithm |
||
22 | */ |
||
23 | private const SHA256 = 'sha256'; |
||
24 | |||
25 | /** |
||
26 | * SHA384 Hash Algorithm |
||
27 | */ |
||
28 | private const SHA384 = 'sha384'; |
||
29 | |||
30 | /** |
||
31 | * SHA512 Hash Algorithm |
||
32 | */ |
||
33 | private const SHA512 = 'sha512'; |
||
34 | |||
35 | /** |
||
36 | * Builder constructor. |
||
37 | */ |
||
38 | public function __construct() |
||
42 | |||
43 | /** |
||
44 | * Constructs a valid SRI string |
||
45 | * |
||
46 | * @param string $file |
||
47 | * |
||
48 | * |
||
49 | * @return string |
||
50 | * @throws Exception |
||
51 | */ |
||
52 | public function sri(string $file) |
||
60 | |||
61 | /** |
||
62 | * Constructs a query string containing the md5 hash of the input file |
||
63 | * |
||
64 | * @param string $file |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function versioning(string $file) |
||
72 | |||
73 | /** |
||
74 | * Sets the HTML attribute based on the file extension and throws an exception if invalid |
||
75 | * |
||
76 | * @param string $path |
||
77 | * |
||
78 | * @return string |
||
79 | * @throws Exception |
||
80 | */ |
||
81 | public function attribute(string $path): string |
||
98 | |||
99 | /** |
||
100 | * Checks config for hash algorithm and if nothing is found default to SHA384 |
||
101 | * |
||
102 | * @return string |
||
103 | * @throws Exception |
||
104 | */ |
||
105 | private static function selectAlgorithm(): string |
||
121 | |||
122 | /** |
||
123 | * Removes everything but the short extension |
||
124 | * |
||
125 | * @param string $path |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | private static function parseExtension(string $path): string |
||
133 | |||
134 | } |
||
135 |