Passed
Push — develop ( 71b03c...334703 )
by Brent
32:34 queued 24:49
created

HeaderContainer::valid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pageon\Http;
4
5
use Iterator;
6
7
class HeaderContainer implements Iterator
8
{
9
    private $position;
10
11
    private $headers = [];
12
13
    public function add(Header $header): HeaderContainer
14
    {
15
        $this->position = 0;
16
        $this->headers[] = $header;
17
18
        return $this;
19
    }
20
21
    public function current(): Header
22
    {
23
        return $this->headers[$this->position];
24
    }
25
26
    public function next(): void
27
    {
28
        ++$this->position;
29
    }
30
31
    public function key(): int
32
    {
33
        return $this->position;
34
    }
35
36
    public function valid(): bool
37
    {
38
        return isset($this->headers[$this->position]);
39
    }
40
41
    public function rewind(): void
42
    {
43
        $this->position = 0;
44
    }
45
}
46