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 | * Constructs a valid SRI string |
||
37 | * |
||
38 | * @param string $file |
||
39 | * |
||
40 | * |
||
41 | * @return string |
||
42 | * @throws Exception |
||
43 | */ |
||
44 | public function sri(string $file) |
||
52 | |||
53 | /** |
||
54 | * Constructs a query string containing the md5 hash of the input file |
||
55 | * |
||
56 | * @param string $file |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public function versioning(string $file) |
||
64 | |||
65 | /** |
||
66 | * Sets the HTML attribute based on the file extension and throws an exception if invalid |
||
67 | * |
||
68 | * @param string $file |
||
69 | * |
||
70 | * @return string |
||
71 | * @throws Exception |
||
72 | */ |
||
73 | public function attribute(string $file): string |
||
90 | |||
91 | /** |
||
92 | * Constructs crossOrigin attribute |
||
93 | * |
||
94 | * @param string $keyword |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | public function crossOrigin(string $keyword): string |
||
102 | |||
103 | /** |
||
104 | * Checks config for hash algorithm and if nothing is found default to SHA384 |
||
105 | * |
||
106 | * @return string |
||
107 | * @throws Exception |
||
108 | */ |
||
109 | private static function selectAlgorithm(): string |
||
125 | |||
126 | /** |
||
127 | * Removes everything but the short extension |
||
128 | * |
||
129 | * @param string $path |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | private static function parseExtension(string $path): string |
||
137 | |||
138 | } |
||
139 |