CanIterate   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 28
ccs 13
cts 13
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 4 1
A key() 0 4 1
A next() 0 4 1
A rewind() 0 4 1
A valid() 0 5 1
1
<?php
2
3
namespace Equip\Structure\Traits;
4
5
trait CanIterate /* implements Iterator */
6
{
7 4
    public function current()
8
    {
9 4
        return current($this->values);
0 ignored issues
show
Bug introduced by
The property values 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...
10
    }
11
12 4
    public function key()
13
    {
14 4
        return key($this->values);
15
    }
16
17 4
    public function next()
18
    {
19 4
        next($this->values);
20 4
    }
21
22 4
    public function rewind()
23
    {
24 4
        reset($this->values);
25 4
    }
26
27 4
    public function valid()
28
    {
29 4
        $key = $this->key();
30 4
        return isset($this->values[$key]);
31
    }
32
}
33