Test Failed
Pull Request — main (#64)
by Lode
08:15
created

HttpStatusCodeManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setHttpStatusCode() 0 7 2
A hasHttpStatusCode() 0 3 1
A getHttpStatusCode() 0 3 1
1
<?php
2
3
namespace alsvanzelf\jsonapi\helpers;
4
5
use alsvanzelf\jsonapi\exceptions\InputException;
6
use alsvanzelf\jsonapi\helpers\Validator;
7
8
trait HttpStatusCodeManager {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait HttpStatusCodeManager
Loading history...
9
	/** @var int */
0 ignored issues
show
Bug introduced by
Expected "integer" but found "int" for @var tag in member variable comment
Loading history...
10
	protected $httpStatusCode;
11
	
12
	/**
13
	 * spec api
14
	 */
15
	
16
	/**
17
	 * @param int $httpStatusCode
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
18
	 * 
19
	 * @throws InputException if an invalid code is used
20
	 */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
21
	public function setHttpStatusCode($httpStatusCode) {
22
		if (Validator::checkHttpStatusCode($httpStatusCode) === false) {
23
			throw new InputException('can not use an invalid http status code');
24
		}
25
		
26
		$this->httpStatusCode = $httpStatusCode;
27
	}
28
	
29
	/**
30
	 * internal api
31
	 */
32
	
33
	/**
34
	 * @internal
35
	 * 
36
	 * @return boolean
37
	 */
38
	public function hasHttpStatusCode() {
39
		return ($this->httpStatusCode !== null);
40
	}
41
	
42
	/**
43
	 * @internal
44
	 * 
45
	 * @return int
46
	 */
47
	public function getHttpStatusCode() {
48
		return $this->httpStatusCode;
49
	}
50
}
51