Completed
Push — master ( 9eccde...ce6277 )
by Lars
02:25
created

ArrayyIterator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
dl 0
loc 43
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A current() 0 10 2
A offsetGet() 0 10 2
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 52.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Arrayy;
4
5
/**
6
 * Class ArrayyIterator
7
 *
8
 * @package Arrayy
9
 */
10
class ArrayyIterator extends \ArrayIterator
11
{
12
  /**
13
   * ArrayyIterator constructor.
14
   *
15
   * @param array $array
16
   * @param int   $flags
17
   */
18 19
  public function __construct(array $array = array(), $flags = 0)
19
  {
20 19
    parent::__construct($array, $flags);
21 19
  }
22
23
  /**
24
   * @return Arrayy|mixed will return a "Arrayy"-object instead of an array
25
   */
26 18
  public function current()
27
  {
28 18
    $value = parent::current();
29
30 18
    if (is_array($value)) {
31 2
      $value = Arrayy::create($value);
32
    }
33
34 18
    return $value;
35
  }
36
37
  /**
38
   * @param string $offset
39
   *
40
   * @return Arrayy|mixed will return a "Arrayy"-object instead of an array
41
   */
42
  public function offsetGet($offset)
43
  {
44
    $value = parent::offsetGet($offset);
45
46
    if (is_array($value)) {
47
      $value = Arrayy::create($value);
48
    }
49
50
    return $value;
51
  }
52
};
53