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   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 55
rs 10
c 1
b 0
f 1

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 9 2
A key() 0 4 1
A current() 0 4 1
A next() 0 4 1
A prev() 0 4 1
A rewind() 0 4 1
A valid() 0 4 1
A seek() 0 8 2
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
}