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   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 10
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValidContentType() 0 3 1
B isAccepted() 0 22 9
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