Kint_Parsers_Json   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 8
cts 14
cp 0.5714
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
C _parse() 0 23 9
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