Conditions | 9 |
Paths | 9 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 9 |
Changes | 0 |
1 | <?php |
||
21 | 3 | public static function isAccepted($sContentType, $aContentTypes) { |
|
22 | 3 | list ($sType, $sSubtype) = explode('/', $sContentType); |
|
23 | 3 | foreach ($aContentTypes as $sAcceptedContentType) { |
|
24 | 2 | list ($sAcceptedType, $sAcceptedSubtype) = explode('/', $sAcceptedContentType); |
|
25 | 2 | $iSemicolonPosition = strpos($sAcceptedSubtype, ';'); |
|
26 | 2 | if ($iSemicolonPosition > 0) { |
|
27 | // discarding the data after the semicolon in the accepts entry |
||
28 | 1 | $sAcceptedSubtype = substr($sAcceptedSubtype, 0, $iSemicolonPosition); |
|
29 | } |
||
30 | |||
31 | 2 | if ($sAcceptedType == $sType && $sAcceptedSubtype == $sSubtype) { |
|
32 | 2 | return true; |
|
33 | } |
||
34 | 2 | if ($sAcceptedType == $sType && $sAcceptedSubtype == '*') { |
|
35 | 1 | return true; |
|
36 | } |
||
37 | 2 | if ($sAcceptedType == '*' && $sAcceptedSubtype == '*') { |
|
38 | 2 | return true; |
|
39 | } |
||
40 | } |
||
41 | 3 | return false; |
|
42 | } |
||
43 | } |
||
44 |