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.

ModelCollectionOrdered::key()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pnz\MattermostClient\Model;
6
7
abstract class ModelCollectionOrdered extends ModelCollection
8
{
9
    /**
10
     * @var string[]
11
     */
12
    protected $order = [];
13
14
    /**
15
     * {@inheritdoc}
16
     */
17 4
    public static function createFromArray(array $data)
18
    {
19 4
        $collection = new static();
20
21 4
        foreach ($data[static::getItemsDataName()] as $itemId => $itemData) {
22 3
            $collection->items[$itemId] = $collection->createItem($itemData);
23
        }
24 4
        $collection->order = $data['order'];
25
26 4
        return $collection;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 3
    public function current()
33
    {
34 3
        return $this->items[$this->order[$this->key]];
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 3
    public function key()
41
    {
42 3
        return $this->order[$this->key];
43
    }
44
45 3
    public function valid(): bool
46
    {
47 3
        return $this->key < \count($this->order);
48
    }
49
50
    /**
51
     * @return string[]
52
     */
53 3
    public function getOrder(): array
54
    {
55 3
        return $this->order;
56
    }
57
58
    /**
59
     * Returns the name of the data containing the items to be sorted.
60
     */
61
    abstract protected static function getItemsDataName(): string;
62
}
63