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

PageOuvrageCollectionDTO   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 9
dl 0
loc 33
rs 10
c 1
b 0
f 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 3 1
A next() 0 3 1
A __construct() 0 3 1
A key() 0 3 1
A valid() 0 3 1
A rewind() 0 3 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
}