HttpStatusTrait::httpStatusCode()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 2
nop 2
1
<?php
2
/**
3
 * HttpStatus.php
4
 * @author      Marc-André Appel <[email protected]>
5
 * @copyright   2018 Hybride Conseil
6
 * @license     http://opensource.org/licenses/MIT MIT
7
 * @link        https://www.hybride-conseil.fr
8
 * @created     19/06/2018
9
 */
10
11
namespace MarcAndreAppel\HttpStatus;
12
13
14
trait HttpStatusTrait
15
{
16
	public function httpStatusCode(int $code = null, array $args = null): object
17
	{
18
		$httpStatus = new HttpStatus($code);
19
		$httpStatus->code = $code;
20
21
		if ( ! is_null($args)) {
22
			foreach ($args as $key => $value) {
23
				if (property_exists($httpStatus, $key)) $httpStatus->$key = $value;
24
			}
25
		}
26
27
		return $httpStatus;
28
	}
29
}
30
31