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.
Completed
Push — master ( 9660af...404e10 )
by Ema
02:17
created

ModelCollection::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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 3
    protected function __construct()
22
    {
23 3
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 3
    public static function createFromArray(array $data)
29
    {
30 3
        $collection = new static();
31 3
        foreach ($data as $itemData) {
32 3
            $collection->items[] = $collection->createItem($itemData);
33
        }
34
35 3
        return $collection;
36
    }
37
38
    /**
39
     * @return array
40
     */
41
    public function getItems()
42
    {
43
        return $this->items;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 3
    public function count()
50
    {
51 3
        return count($this->items);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function key()
58
    {
59
        return $this->key;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function next()
66
    {
67
        ++$this->key;
68
    }
69
70
    /**
71
     * @return bool
72
     */
73
    public function valid()
74
    {
75
        return $this->key < $this->count();
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81 3
    public function current()
82
    {
83 3
        return $this->items[$this->key];
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function rewind()
90
    {
91
        $this->key = 0;
92
    }
93
94
    /**
95
     * @param array $data
96
     */
97
    abstract protected function createItem(array $data);
98
}
99