Reader::peek()   A
last analyzed

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
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