Completed
Push — master ( 5fca22...233410 )
by Emily
01:43
created

OuterIteratorTrait::valid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of the Composite Utils package.
4
 *
5
 * (c) Emily Shepherd <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the
8
 * LICENSE.md file that was distributed with this source code.
9
 *
10
 * @package spaark/composite-utils
11
 * @author Emily Shepherd <[email protected]>
12
 * @license MIT
13
 */
14
15
namespace Spaark\CompositeUtils\Model\Collection;
16
17
use Iterator;
18
19
/**
20
 * A trait which implements all of the methods required by the
21
 * OuterIterator trait
22
 *
23
 * The default implementations simply pass through all requests onto
24
 * the inner iterator.
25
 */
26
trait OuterIteratorTrait
27
{
28
    /**
29
     * Advances the inner iterator's pointer
30
     */
31 2
    public function next()
32
    {
33 2
        return $this->iterator->next();
0 ignored issues
show
Bug introduced by
The property iterator does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
    }
35
36
    /**
37
     * Returns the inner iterator's current value
38
     *
39
     * @return mixed
40
     */
41 2
    public function current()
42
    {
43 2
        return $this->iterator->current();
44
    }
45
46
    /**
47
     * Returns the inner iterator's current key
48
     *
49
     * @return scalar
50
     */
51 2
    public function key()
52
    {
53 2
        return $this->iterator->key();
54
    }
55
56
    /**
57
     * Resets the inner iterator
58
     */
59 2
    public function rewind()
60
    {
61 2
        return $this->iterator->rewind();
62
    }
63
64
    /**
65
     * Returns if the inner iterator is still valid
66
     *
67
     * @return boolean
68
     */
69 2
    public function valid()
70
    {
71 2
        return $this->iterator->valid();
72
    }
73
74
    /**
75
     * Returns the inner iterator
76
     *
77
     * @return Iterator
78
     */
79 4
    public function getInnerIterator() : Iterator
80
    {
81 4
        return $this->iterator;
82
    }
83
}
84