Reader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A next() 0 5 1
A peek() 0 4 1
A hasNext() 0 4 1
1
<?php
2
namespace Desmond;
3
4
class Reader
5
{
6
    private $position = 0;
7
    private $characters;
8
9 357
    public function __construct(array $characters)
10
    {
11 357
        $this->characters = $characters;
12 357
    }
13
14 353
    public function next()
15
    {
16 353
        $this->position++;
17 353
        return $this;
18
    }
19
20 356
    public function peek()
21
    {
22 356
        return $this->characters[$this->position] ?? null;
23
    }
24
25 1
    public function hasNext()
26
    {
27 1
        return isset($this->characters[$this->position + 1]);
28
    }
29
}
30