| Conditions | 8 |
| Paths | 6 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 8 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 45 | public function isContentTypeSupported(string $fullContentType, array $supportedContentTypes): bool |
|
| 17 | { |
||
| 18 | 45 | $contentType = $this->removeDirectives($fullContentType); |
|
| 19 | 45 | foreach ($supportedContentTypes as $availableContentType) { |
|
| 20 | 45 | if ($contentType === $availableContentType) { |
|
| 21 | 28 | return true; |
|
| 22 | } |
||
| 23 | |||
| 24 | 38 | if ($availableContentType === '*') { |
|
| 25 | 2 | return true; |
|
| 26 | } |
||
| 27 | |||
| 28 | 36 | $availableParts = explode('/', $availableContentType, 2); |
|
| 29 | 36 | $providedParts = explode('/', $contentType, 2); |
|
| 30 | |||
| 31 | 36 | if (count($availableParts) < 2 || count($providedParts) < 2) { |
|
| 32 | 21 | continue; |
|
| 33 | } |
||
| 34 | |||
| 35 | 16 | if ($availableParts[0] === $providedParts[0] && $availableParts[1] === '*') { |
|
| 36 | 16 | return true; |
|
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | 11 | return false; |
|
| 41 | } |
||
| 42 | |||
| 48 |