Completed
Push — master ( 5adf1c...8a340c )
by Lars
03:32
created

Kint_Parsers_Json::_parse()   C

Complexity

Conditions 9
Paths 3

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 15.3773

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
ccs 8
cts 14
cp 0.5714
rs 5.8541
cc 9
eloc 15
nc 3
nop 1
crap 15.3773
1
<?php
2
3
namespace kint\parsers\custom;
4
5
use kint\inc\KintParser;
6
7
/**
8
 * Class Kint_Parsers_Json
9
 */
10
class Kint_Parsers_Json extends KintParser
11
{
12
  /**
13
   * @param mixed $variable
14
   *
15
   * @return bool
16
   */
17 1
  protected function _parse(&$variable)
18
  {
19
    if (
20 1
        is_object($variable)
21 1
        || is_array($variable)
22 1
        || (string)$variable !== $variable
23 1
        || !isset($variable[0])
24 1
        || ($variable[0] !== '{' && $variable[0] !== '[')
25 1
        || ($json = json_decode($variable, true)) === null
26
    ) {
27 1
      return false;
28
    }
29
30
    $val = (array)$json;
31
    if (empty($val)) {
32
      return false;
33
    }
34
35
    $this->value = KintParser::factory($val)->extendedValue;
0 ignored issues
show
Documentation Bug introduced by
It seems like \kint\inc\KintParser::fa...ry($val)->extendedValue of type array<integer,object<kint\inc\KintVariableData>> is incompatible with the declared type string of property $value.

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...
36
    $this->type = 'JSON';
37
38
    return true;
39
  }
40
}
41