Passed
Branch master (309757)
by Dispositif
03:20 queued 54s
created

PageOuvrageCollectionDTO::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 1
cc 1
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019-2023 © Philippe M./Irønie  <[email protected]>
5
 * For the full copyright and MIT license information, view the license file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Domain\Models;
11
12
use Iterator;
13
14
class PageOuvrageCollectionDTO implements Iterator
15
{
16
    private $items = [];
17
    private $pointer = 0;
18
19
    public function __construct(array $items)
20
    {
21
        $this->items = array_values($items);
22
    }
23
24
    public function current(): PageOuvrageDTO
25
    {
26
        return $this->items[$this->pointer];
27
    }
28
29
    public function key(): int
30
    {
31
        return $this->pointer;
32
    }
33
34
    public function next(): void
35
    {
36
        $this->pointer++;
37
    }
38
39
    public function rewind(): void
40
    {
41
        $this->pointer = 0;
42
    }
43
44
    public function valid(): bool
45
    {
46
        return $this->pointer < count($this->items);
47
    }
48
}