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.
Passed
Push — master ( 602110...9e304b )
by Steeven
02:47
created

Result   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 99
rs 10
c 0
b 0
f 0
wmc 15

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setInfo() 0 5 1
B __construct() 0 35 10
A pagination() 0 9 3
A getInfo() 0 3 1
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Framework\Models\Sql\DataObjects;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Database\DataObjects\Result\Info;
19
use O2System\Framework\Libraries\Ui\Components\Pagination;
20
use O2System\Framework\Models\Sql\Model;
21
use O2System\Spl\Iterators\ArrayIterator;
22
23
/**
24
 * Class Result
25
 *
26
 * @package O2System\Database\DataStructures
27
 */
28
class Result extends ArrayIterator
29
{
30
    /**
31
     * Result::$info
32
     *
33
     * @var Info
34
     */
35
    public $info;
36
37
    // ------------------------------------------------------------------------
38
39
    /**
40
     * Result::__construct
41
     *
42
     * @param \O2System\Database\DataObjects\Result $result
43
     * @param \O2System\Framework\Models\Sql\Model  $model
44
     */
45
    public function __construct(\O2System\Database\DataObjects\Result $result, Model &$model)
46
    {
47
        if ($result->count() > 0) {
48
            $ormResult = new \SplFixedArray($result->count());
49
50
            foreach ($result as $key => $row) {
51
                if (method_exists($model, 'rebuildRow')) {
52
                    $row = $model->rebuildRow($row);
0 ignored issues
show
Bug introduced by
The method rebuildRow() does not exist on O2System\Framework\Models\Sql\Model. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
                    /** @scrutinizer ignore-call */ 
53
                    $row = $model->rebuildRow($row);
Loading history...
53
                }
54
55
                // Visible Columns
56
                if (count($model->visibleColumns)) {
57
                    $columns = $row->getColumns();
58
                    foreach ($columns as $column) {
59
                        if ( ! in_array($column, $model->visibleColumns)) {
60
                            array_push($model->hideColumns, $column);
61
                        }
62
                    }
63
                }
64
65
                // Hide Columns
66
                if (count($model->hideColumns)) {
67
                    foreach ($model->hideColumns as $column) {
68
                        if ($row->offsetExists($column)) {
69
                            $row->offsetUnset($column);
70
                        }
71
                    }
72
                }
73
74
                $ormResult[ $key ] = new Result\Row($row, $model);
0 ignored issues
show
Bug introduced by
It seems like $row can also be of type boolean; however, parameter $row of O2System\Framework\Model...sult\Row::__construct() does only seem to accept O2System\Database\DataObjects\Result\Row|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

74
                $ormResult[ $key ] = new Result\Row(/** @scrutinizer ignore-type */ $row, $model);
Loading history...
75
            }
76
77
            parent::__construct($ormResult->toArray());
78
79
            unset($ormResult);
80
        }
81
    }
82
83
    // ------------------------------------------------------------------------
84
85
    /**
86
     * Result::setInfo
87
     *
88
     * @param \O2System\Database\DataObjects\Result\Info $info
89
     *
90
     * @return static
91
     */
92
    public function setInfo(Info $info)
93
    {
94
        $this->info = $info;
95
96
        return $this;
97
    }
98
99
    // ------------------------------------------------------------------------
100
101
    /**
102
     * Result::getInfo
103
     *
104
     * @return \O2System\Database\DataObjects\Result\Info
105
     */
106
    public function getInfo()
107
    {
108
        return $this->info;
109
    }
110
111
    // ------------------------------------------------------------------------
112
113
    /**
114
     * Result::pagination
115
     *
116
     * @return \O2System\Framework\Libraries\Ui\Components\Pagination
117
     */
118
    public function pagination()
119
    {
120
        $rows = $this->info->getTotal()->rows;
121
        $rows = empty($rows) ? 0 : $rows;
122
123
        $limit = input()->get('limit');
124
        $limit = empty($limit) ? $this->info->limit : $limit;
125
126
        return new Pagination($rows, $limit);
0 ignored issues
show
Bug introduced by
It seems like $limit can also be of type O2System\Spl\DataStructures\SplArrayObject; however, parameter $limit of O2System\Framework\Libra...gination::__construct() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

126
        return new Pagination($rows, /** @scrutinizer ignore-type */ $limit);
Loading history...
127
    }
128
}