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.
Test Setup Failed
Push — master ( e039e4...016889 )
by Gabriel
04:43
created

SortingTrait::ksort()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Collections\Traits;
4
5
/**
6
 * Class SortingTrait
7
 * @package Nip\Collections\Traits
8
 */
9
trait SortingTrait
10
{
11
    /**
12
     * @return mixed
13
     */
14
    public function end()
15
    {
16
        $this->index = count($this->items);
0 ignored issues
show
Bug introduced by
The property index does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property items does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
        return end($this->items);
18
    }
19
20
    /**
21
     * @return mixed
22
     */
23
    public function current()
24
    {
25
        return current($this->items);
26
    }
27
28
    /**
29
     * @return mixed
30
     */
31
    public function next()
32
    {
33
        $this->index++;
34
        return next($this->items);
35
    }
36
    /**
37
     * @return mixed
38
     */
39
    public function rewind()
40
    {
41
        $this->index = 0;
42
43
        return reset($this->items);
44
    }
45
46
    /**
47
     * @return $this
48
     */
49
    public function ksort()
50
    {
51
        ksort($this->items);
52
        $this->rewind();
53
        return $this;
54
    }
55
56
    /**
57
     * @param $callback
58
     * @return $this
59
     */
60
    public function usort($callback)
61
    {
62
        usort($this->items, $callback);
63
        $this->rewind();
64
        return $this;
65
    }
66
67
    /**
68
     * @param $callback
69
     * @return $this
70
     */
71
    public function uasort($callback)
72
    {
73
        uasort($this->items, $callback);
74
        $this->rewind();
75
        return $this;
76
    }
77
78
    /**
79
     * @return $this
80
     */
81
    public function shuffle()
82
    {
83
        shuffle($this->items);
84
        $this->rewind();
85
        return $this;
86
    }
87
}
88