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

Kint_Parsers_SplObjectStorage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 29.4%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 37
ccs 5
cts 17
cp 0.294
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B _parse() 0 29 5
1
<?php
2
3
namespace kint\parsers\custom;
4
5
use kint\inc\KintParser;
6
7
/**
8
 * Class Kint_Parsers_SplObjectStorage
9
 */
10
class Kint_Parsers_SplObjectStorage 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
        ||
22
        !$variable instanceof \SplObjectStorage
23 1
    ) {
24 1
      return false;
25
    }
26
27
    /** @var $variable \SplObjectStorage */
28
29
    $count = $variable->count();
30
    if ($count === 0) {
31
      return false;
32
    }
33
34
    $variable->rewind();
35
    while ($variable->valid()) {
36
      $current = $variable->current();
37
      $this->value[] = KintParser::factory($current);
38
      $variable->next();
39
    }
40
41
    $this->type = 'Storage contents';
42
    $this->size = $count;
43
44
    return true;
45
  }
46
}
47