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.
Completed
Push — master ( 7b42e1...c93f43 )
by Marius
10:41 queued 04:09
created

JsonReader::buildObj()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 0
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package domain
4
 * @subpackage models
5
 * @author marius orcsik <[email protected]>
6
 * @date 2010.04.13
7
 */
8
namespace vsc\domain\models;
9
10
use vsc\domain\ExceptionDomain;
11
use vsc\ExceptionUnimplemented;
12
13
class JsonReader extends ModelA {
14
	private $sJsonString;
15
	private $oPayload;
16
17 1
	public function __construct() {
18 1
		if (!extension_loaded('json')) {
19
			throw new ExceptionUnimplemented('The JSON extension is not loaded');
20
		}
21 1
		parent::__construct();
22 1
	}
23
24 1
	public function setString($sString) {
25 1
		$this->sJsonString = $sString;
26 1
	}
27
28 1
	public function getString() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
29 1
		return $this->sJsonString;
30
	}
31
32 1
	public function __get($sIncName = null) {
33
		try {
34 1
			$oProperty = new \ReflectionProperty($this, $sIncName);
35
			if ($oProperty->isPublic()) {
36
				return $oProperty->getValue($this);
37
			}
38 1
		} catch (\ReflectionException $e) {
39
			//
40
		}
41 1
		return parent::__get($sIncName);
42
	}
43
44 1
	public function __set($sIncName, $mValue) {
45 1
		if (is_null($sIncName)) {
46
			throw new \ReflectionException('Can\'t set a value to a null property on the current object [' . get_class($this) . ']');
47
		}
48
		try {
49 1
			$oProperty = new \ReflectionProperty($this->oPayload, $sIncName);
50
			if ($oProperty->isPublic()) {
51
				$oProperty->setValue($this->oPayload, $mValue);
52
			}
53
			return;
54 1
		} catch (\ReflectionException $e) {
55 1
			$this->$sIncName = $mValue;
56
		}
57 1
	}
58
59
	/**
60
	 * @param integer $iError
61
	 * @return string
62
	 */
63 5
	public static function getError($iError) {
64
		switch ($iError) {
65 5
		case JSON_ERROR_DEPTH:
66 1
			$sLastError = 'Maximum stack depth exceeded';
67 1
			break;
68 4
		case JSON_ERROR_CTRL_CHAR:
69 1
			$sLastError = 'Unexpected control character found';
70 1
			break;
71 3
		case JSON_ERROR_SYNTAX:
72 1
			$sLastError = 'Syntax error, malformed JSON';
73 1
			break;
74 2
		case JSON_ERROR_NONE:
75
		default:
76 2
			$sLastError = 'No errors';
77 2
			break;
78
		}
79 5
		return $sLastError;
80
	}
81
82 1
	public function buildObj() {
83 1
		$oPayload = json_decode($this->sJsonString);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
84 1
		$iLastError = json_last_error();
85 1
		if (!$iLastError) {
86 1
			foreach ($oPayload as $sName => $oStd) {
87 1
				$this->$sName = $oStd;
88
			}
89
		} else {
90
			throw new ExceptionDomain('The JSON string contains errors: [' . static::getError($iLastError) . ']');
91
		}
92 1
	}
93
}
94