Completed
Push — master ( 8a340c...157d96 )
by Lars
03:22
created

Kint_Parsers_ObjectIterateable   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 46.15%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 31
ccs 6
cts 13
cp 0.4615
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B _parse() 0 23 5
1
<?php
2
3
namespace kint\parsers\custom;
4
5
use kint\inc\KintParser;
6
7
/**
8
 * Class Kint_Parsers_ObjectIterateable
9
 *
10
 * @package kint\parsers\custom
11
 */
12
class Kint_Parsers_ObjectIterateable extends KintParser
13
{
14
  /**
15
   * @param mixed $variable
16
   *
17
   * @return bool
18
   */
19 1
  protected function _parse(&$variable)
20
  {
21
    if (
22 1
        !is_object($variable)
23 1
        || !$variable instanceof \Traversable
24 1
        || stripos(get_class($variable), 'zend') !== false // zf2 PDO wrapper does not play nice
25 1
    ) {
26 1
      return false;
27
    }
28
29
30
    $arrayCopy = iterator_to_array($variable, true);
31
32
    if ($arrayCopy === false) {
33
      return false;
34
    }
35
36
    $this->value = KintParser::factory($arrayCopy)->extendedValue;
0 ignored issues
show
Documentation Bug introduced by
It seems like \kint\inc\KintParser::fa...rayCopy)->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...
37
    $this->type = 'Iterator contents';
38
    $this->size = count($arrayCopy);
39
40
    return true;
41
  }
42
}
43