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.

ErrorProcessor   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 50
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 5

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorCode() 0 10 2
A __construct() 0 11 2
A getModel() 0 3 1
A init() 0 1 1
A setException() 0 7 2
A handleRequest() 0 3 1
1
<?php
2
/**
3
 * @package presentation
4
 * @subpackage processors
5
 * @author marius orcsik <[email protected]>
6
 * @date 11.05.17
7
 */
8
namespace vsc\application\processors;
9
10
use vsc\application\sitemaps\ErrorProcessorMap;
11
use vsc\domain\models\EmptyModel;
12
use vsc\domain\models\ErrorModel;
13
use vsc\presentation\requests\HttpRequestA;
14
use vsc\presentation\responses\ExceptionResponseError;
15
16
class ErrorProcessor extends ProcessorA implements ErrorProcessorInterface {
17
	/**
18
	 * @var ErrorModel
19
	 */
20
	private $model;
21
22 3
	public function getErrorCode() {
23
		/** @var ErrorModel $oErrorModel */
24 3
		$oErrorModel = $this->getModel();
25 3
		$e = $oErrorModel->getException();
26 3
		if ($e instanceof ExceptionResponseError) {
27 2
			return $e->getCode();
28
		} else {
29 1
			return 500;
30
		}
31
	}
32
33 10
	public function __construct(\Exception $e = null) {
34 10
		if (!is_null($e)) {
35 9
			$this->setException($e);
36
		}
37
38 10
		$oErrorMap = new ErrorProcessorMap();
39 10
		$oErrorMap->setTemplatePath(VSC_SRC_PATH . 'templates');
40 10
		$oErrorMap->setTemplate('error.tpl.php');
41
42 10
		$this->setMap($oErrorMap);
43 10
	}
44
45
	/**
46
	 * @return ErrorModel
47
	 */
48 2
	public function getModel() {
49 2
		return $this->model;
50
	}
51
52
	public function init() {}
53
54 10
	public function setException(\Exception $e = null) {
55 10
		if (!is_null($e)) {
56 9
			$this->model = new ErrorModel($e);
57
		} else {
58 1
			$this->model = new EmptyModel();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \vsc\domain\models\EmptyModel() of type object<vsc\domain\models\EmptyModel> is incompatible with the declared type object<vsc\domain\models\ErrorModel> of property $model.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
59
		}
60 10
	}
61
62 1
	public function handleRequest(HttpRequestA $oHttpRequest) {
63 1
		return $this->getModel();
64
	}
65
}
66