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.

ArrayAdapter::getSource()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace ZfTable\Source;
3
4
use ZfTable\Source\AbstractSource;
5
use Zend\Paginator\Paginator;
6
7
class ArrayAdapter extends AbstractSource
8
{
9
10
    /**
11
     *
12
     * @var \ArrayObject
13
     */
14
    protected $arraySource;
15
16
    /**
17
     *
18
     * @var  \Zend\Paginator\Paginator
19
     */
20
    protected $paginator;
21
22
    /**
23
     *
24
     * @param \ArrayObject $arraySource
25
     */
26
    public function __construct($arraySource)
27
    {
28
        $this->arraySource = new \ArrayObject($arraySource)   ;
29
    }
30
31
    /**
32
     *
33
     * @return \Zend\Paginator\Paginator
34
     */
35
    public function getPaginator()
36
    {
37
        if (!$this->paginator) {
38
39
            $this->arraySource  = (array) $this->arraySource;
0 ignored issues
show
Documentation Bug introduced by
It seems like (array) $this->arraySource of type array is incompatible with the declared type object<ArrayObject> of property $arraySource.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
            $this->order();
41
42
             $adapter = new \Zend\Paginator\Adapter\ArrayAdapter((array) $this->arraySource);
43
             $this->paginator = new Paginator($adapter);
44
             $this->initPaginator();
45
46
        }
47
        return $this->paginator;
48
    }
49
50
51
    protected function order()
52
    {
53
54
        $column = $this->getParamAdapter()->getColumn();
55
        $order = $this->getParamAdapter()->getOrder();
56
57
        if (!$column) {
58
            return;
59
        }
60
61
        uasort($this->arraySource, function ($i, $j) use ($column, $order) {
62
63
            $a = $i[$column];
64
            $b = $j[$column];
65
66
            $condition = ($order == 'asc') ? $a > $b : $a < $b;
67
68
            if ($a == $b) {
69
                return 0;
70
            } elseif ($condition) {
71
                return 1;
72
            } else {
73
                return -1;
74
            }
75
        });
76
    }
77
78
79
    public function getSource()
80
    {
81
        return $this->arraySource;
82
    }
83
}
84