GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ContentType::isAccepted()   B
last analyzed

Complexity

Conditions 9
Paths 9

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 9

Importance

Changes 0
Metric Value
cc 9
nc 9
nop 2
dl 0
loc 22
ccs 14
cts 14
cp 1
crap 9
rs 8.0555
c 0
b 0
f 0
1
<?php
2
namespace vsc\presentation\requests;
3
4
use vsc\infrastructure\Base;
5
6
class ContentType extends Base {
7
8
	/**
9
	 * @param string $sContentType
10
	 * @return bool
11
	 */
12 22
	public static function isValidContentType($sContentType) {
13 22
		return (preg_match('/^([-a-z]+|\*{1})\/([-a-z\+\.]+|\*{1})(;.*)?$/i', $sContentType) > 0);
14
	}
15
16
	/**
17
	 * @param $sContentType
18
	 * @param $aContentTypes
19
	 * @return bool
20
	 */
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