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.

JsonView::outputModel()   B
last analyzed

Complexity

Conditions 6
Paths 24

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 6.105

Importance

Changes 0
Metric Value
cc 6
nc 24
nop 1
dl 0
loc 25
ccs 12
cts 14
cp 0.8571
crap 6.105
rs 8.8977
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package presentation
4
 * @subpackage views
5
 * @author marius orcsik <[email protected]>
6
 * @date 2010.04.09
7
 */
8
namespace vsc\presentation\views;
9
10
use vsc\domain\models\ModelA;
11
12
class JsonView extends ViewA implements JsonViewInterface {
13
	protected $sContentType = 'application/json';
14
	protected $sFolder = 'json';
15
16 1
	public function outputModel($oModel) {
17 1
		$flags = 0; //JSON_FORCE_OBJECT;
18
19 1
		if (phpversion() > '5.3.3') {
20 1
			$flags |= JSON_NUMERIC_CHECK;
21
		}
22 1
		if (phpversion() > '5.4.0') {
23 1
			$flags |= JSON_UNESCAPED_UNICODE;
24 1
			if (\vsc\isDebug()) {
25 1
				$flags |= JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;
26
			}
27
		}
28 1
		if (ModelA::isValid($oModel)) {
29
			/* @var ModelA $oModel */
30
			$sOutput = json_encode($oModel->toArray(), $flags);
31
		} else {
32 1
			$sOutput = json_encode($oModel, $flags);
33
		}
34
35 1
		if (!json_last_error()) {
36 1
			return $sOutput;
37
		} else {
38
			throw new ExceptionView(json_last_error_msg());
39
		}
40
	}
41
}
42