| Total Complexity | 6 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | abstract class ADecoder |
||
| 14 | { |
||
| 15 | /** @var string[] */ |
||
| 16 | protected array $contentEncoded = []; |
||
| 17 | |||
| 18 | 1 | public function getHeaderKey(): string |
|
| 19 | { |
||
| 20 | 1 | return 'Content-Encoding'; |
|
| 21 | } |
||
| 22 | |||
| 23 | 2 | public function canDecode(string $header): bool |
|
| 24 | { |
||
| 25 | 2 | $encode = $this->decodings($header); |
|
| 26 | 2 | foreach ($encode as $coding) { |
|
| 27 | 2 | if (in_array($coding, $this->contentEncoded)) { |
|
| 28 | 2 | return true; |
|
| 29 | } |
||
| 30 | } |
||
| 31 | 1 | return false; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Extract encodings from its compiled content |
||
| 36 | * @param string $headers |
||
| 37 | * @return string[] |
||
| 38 | */ |
||
| 39 | 2 | protected function decodings(string $headers): array |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * In and Out are streams - "file handler" resources |
||
| 51 | * @param resource $content |
||
| 52 | * @return resource |
||
| 53 | */ |
||
| 54 | abstract public function processDecode($content); |
||
| 55 | } |
||
| 56 |