IteratorArray   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 50
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 6 2
A setDefaults() 0 5 1
A setReplace() 0 5 1
1
<?php
2
3
namespace NwLaravel\Iterators;
4
5
use ArrayIterator;
6
7
/**
8
 * Library Iterator Array
9
 */
10
class IteratorArray extends ArrayIterator implements IteratorInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $defaults = array();
16
17
    /**
18
     * @var array
19
     */
20
    protected $replace = array();
21
22
    /**
23
     * Get row current
24
     *
25
     * @return array
26
     */
27 1
    public function current()
28
    {
29 1
        $current = parent::current();
30 1
        $current = is_array($current) ? $current : array();
31 1
        return array_merge($this->defaults, $current, $this->replace);
32
    }
33
34
    /**
35
     * Set Fields Defaults
36
     *
37
     * @param array $defaults Defaults
38
     *
39
     * @return void
40
     */
41 1
    public function setDefaults(array $defaults)
42
    {
43 1
        $this->defaults = $defaults;
44 1
        return $this;
45
    }
46
47
    /**
48
     * Set Fields Replace
49
     *
50
     * @param array $replace Replaces
51
     *
52
     * @return void
53
     */
54 1
    public function setReplace(array $replace)
55
    {
56 1
        $this->replace = $replace;
57 1
        return $this;
58
    }
59
}
60