Total Complexity | 5 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 93.75% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | trait SRITrait { |
||
15 | use SingletonTrait; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $sri = []; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $sriFilename; |
||
26 | |||
27 | /** |
||
28 | * @param string $type |
||
29 | */ |
||
30 | 1 | public function init($type) { |
|
31 | 1 | $this->sriFilename = $type === 'js' ? JS_SRI_FILENAME : CSS_SRI_FILENAME; |
|
32 | /** @var Cache $cache */ |
||
33 | 1 | $cache = Cache::getInstance(); |
|
34 | 1 | $this->sri = $cache->getDataFromFile($this->sriFilename, Cache::JSON, true); |
|
35 | 1 | if(empty($this->sri)) { |
|
36 | 1 | $this->sri = []; |
|
37 | } |
||
38 | 1 | } |
|
39 | |||
40 | /** |
||
41 | * @param $hash |
||
42 | * @param string $type |
||
43 | * @return mixed|string |
||
44 | * @throws \PSFS\base\exception\GeneratorException |
||
45 | */ |
||
46 | 1 | protected function getSriHash($hash, $type = 'js') { |
|
57 | } |
||
58 | } |