| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2.0054 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 46 | 1 | protected function getSriHash($hash, $type = 'js') { |
|
| 47 | 1 | if(array_key_exists($hash, $this->sri)) { |
|
| 48 | $sriHash = $this->sri[$hash]; |
||
| 49 | } else { |
||
| 50 | 1 | Inspector::stats('[SRITrait] Generating SRI for ' . $hash, Inspector::SCOPE_DEBUG); |
|
| 51 | 1 | $filename = WEB_DIR . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $hash . '.' . $type; |
|
| 52 | 1 | $sriHash = base64_encode(hash("sha384", file_get_contents($filename), true)); |
|
| 53 | 1 | $this->sri[$hash] = $sriHash; |
|
| 54 | 1 | Cache::getInstance()->storeData($this->sriFilename, $this->sri, Cache::JSON, true); |
|
| 55 | } |
||
| 56 | 1 | return $sriHash; |
|
| 57 | } |
||
| 58 | } |