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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 3 1
A valid() 0 3 1
A key() 0 3 1
A getOrder() 0 3 1
A createFromArray() 0 10 2
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