GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ModelCollection   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 64
ccs 23
cts 23
cp 1
rs 10
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 3 1
A rewind() 0 3 1
A key() 0 3 1
A count() 0 3 1
A createFromArray() 0 8 2
A valid() 0 3 1
A getItems() 0 3 1
A next() 0 3 1
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pnz\MattermostClient\Model;
6
7
abstract class ModelCollection implements CreatableFromArray, \Countable, \Iterator
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $items = [];
13
14
    /**
15
     * Current iterator key.
16
     *
17
     * @var int
18
     */
19
    protected $key = 0;
20
21 11
    protected function __construct()
22
    {
23 11
    }
24
25 7
    public static function createFromArray(array $data)
26
    {
27 7
        $collection = new static();
28 7
        foreach ($data as $itemData) {
29 6
            $collection->items[] = $collection->createItem($itemData);
30
        }
31
32 7
        return $collection;
33
    }
34
35 2
    public function getItems(): array
36
    {
37 2
        return $this->items;
38
    }
39
40 9
    public function count(): int
41
    {
42 9
        return \count($this->items);
43
    }
44
45 1
    public function key()
46
    {
47 1
        return $this->key;
48
    }
49
50 4
    public function next(): void
51
    {
52 4
        ++$this->key;
53 4
    }
54
55 1
    public function valid(): bool
56
    {
57 1
        return $this->key < $this->count();
58
    }
59
60 6
    public function current()
61
    {
62 6
        return $this->items[$this->key];
63
    }
64
65 2
    public function rewind(): void
66
    {
67 2
        $this->key = 0;
68 2
    }
69
70
    abstract protected function createItem(array $data);
71
}
72