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 ( 352f99...e3c5ff )
by Cees-Jan
09:24
created

IteratorTrait::seek()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 1
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace WyriHaximus\Travis;
4
5
/**
6
 * @source https://github.com/jeremeamia/php-design-patterns/blob/master/src/Jeremeamia/PhpPatterns/Structural/Collection/IteratorTrait.php
7
 */
8
trait IteratorTrait
9
{
10
    private $container;
11
12
    protected function getData()
13
    {
14
        if ($this->container !== null) {
15
            return $this->container;
16
        }
17
18
        $this->container = $this->getClient()->request($this)->getIterator()->getArrayCopy();
0 ignored issues
show
Bug introduced by
It seems like getClient() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
19
        return $this->container;
20
    }
21
22
    protected $position = 0;
23
24
    public function key()
25
    {
26
        return $this->position;
27
    }
28
29
    public function current()
30
    {
31
        return $this->getData()[$this->position];
32
    }
33
34
    public function next()
35
    {
36
        return $this->position++;
37
    }
38
39
    public function prev()
40
    {
41
        return $this->position--;
42
    }
43
44
    public function rewind()
45
    {
46
        return $this->position = 0;
47
    }
48
49
    public function valid()
50
    {
51
        return array_key_exists($this->position, $this->getData());
52
    }
53
54
    public function seek($position)
55
    {
56
        $this->position = $position;
57
58
        if (!$this->valid()) {
59
            throw new \OutOfBoundsException("The key [{$position}] does not exist.");
60
        }
61
    }
62
}