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

HttpStatusCodeManager::setHttpStatusCode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 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