Passed
Push — develop ( 63d0b7...ee8da9 )
by Brent
03:37
created

Site   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getPages() 0 3 1
A setPages() 0 4 1
A addPage() 0 3 1
A rewind() 0 3 1
A current() 0 3 1
A key() 0 3 1
A next() 0 3 1
A valid() 0 3 1
1
<?php
2
3
namespace Brendt\Stitcher\Site;
4
5
use \Iterator;
6
7
class Site implements Iterator
8
{
9
10
    /** @var Page[] */
11
    private $pages;
12
13
    /** @var int */
14
    private $position = 0;
15
16
    public function __construct() {
17
        $this->position = 0;
18
    }
19
20
    public function getPages() : array {
21
        return $this->pages;
22
    }
23
24
    public function setPages(array $pages) {
25
        $this->pages = $pages;
26
        $this->rewind();
27
    }
28
29
    public function addPage(Page $page) {
30
        $this->pages[] = $page;
31
    }
32
33
    public function rewind() {
34
        $this->position = 0;
35
    }
36
37
    public function current() {
38
        return $this->pages[$this->position];
39
    }
40
41
    public function key() {
42
        return $this->position;
43
    }
44
45
    public function next() {
46
        ++$this->position;
47
    }
48
49
    public function valid() {
50
        return isset($this->pages[$this->position]);
51
    }
52
53
}
54