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

Kint_Parsers_SplObjectStorage::_parse()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 29
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 14.8579

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
ccs 4
cts 15
cp 0.2667
rs 8.439
cc 5
eloc 17
nc 4
nop 1
crap 14.8579
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
        ||
22 1
        !$variable instanceof \SplObjectStorage
23
    ) {
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