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 ( bbcfbe...c28c6c )
by Steeven
02:22
created

Result::offsetSet()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 26
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 16
nop 2
dl 0
loc 26
rs 9.6111
c 0
b 0
f 0
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\Info\SplClassInfo;
22
23
/**
24
 * Class Result
25
 *
26
 * @package O2System\Database\DataStructures
27
 */
28
class Result extends \O2System\Database\DataObjects\Result
29
{
30
    /**
31
     * Result::$model
32
     *
33
     * @var Model
34
     */
35
    protected $model;
36
37
    /**
38
     * Result::$info
39
     *
40
     * @var Info
41
     */
42
    protected $info;
43
44
    // ------------------------------------------------------------------------
45
46
    /**
47
     * Result::__construct
48
     *
49
     * @param \O2System\Database\DataObjects\Result $result
50
     * @param \O2System\Framework\Models\Sql\Model  $model
51
     */
52
    public function __construct(\O2System\Database\DataObjects\Result $result, Model &$model)
53
    {
54
        $this->model = new SplClassInfo($model);
0 ignored issues
show
Documentation Bug introduced by
It seems like new O2System\Spl\Info\SplClassInfo($model) of type O2System\Spl\Info\SplClassInfo is incompatible with the declared type O2System\Framework\Models\Sql\Model of property $model.

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...
55
56
        if ( ! models()->has($this->model->getClass())) {
0 ignored issues
show
Bug introduced by
The method has() 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

56
        if ( ! models()->/** @scrutinizer ignore-call */ has($this->model->getClass())) {
Loading history...
Bug introduced by
The method has() does not exist on O2System\Framework\Models\NoSql\Model. ( Ignorable by Annotation )

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

56
        if ( ! models()->/** @scrutinizer ignore-call */ has($this->model->getClass())) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
            models()->add($model, $this->model->getClass());
0 ignored issues
show
Bug introduced by
The method add() 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

57
            models()->/** @scrutinizer ignore-call */ add($model, $this->model->getClass());
Loading history...
Bug introduced by
The method add() does not exist on O2System\Framework\Models\NoSql\Model. ( Ignorable by Annotation )

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

57
            models()->/** @scrutinizer ignore-call */ add($model, $this->model->getClass());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
58
        }
59
60
        $this->info = $result->getInfo();
61
        parent::__construct($result->toArray());
0 ignored issues
show
Bug introduced by
The method toArray() does not exist on O2System\Database\DataObjects\Result. Did you maybe mean __toArray()? ( Ignorable by Annotation )

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

61
        parent::__construct($result->/** @scrutinizer ignore-call */ toArray());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
62
    }
63
64
    // ------------------------------------------------------------------------
65
66
    /**
67
     * Result::offsetSet
68
     *
69
     * @param mixed $offset
70
     * @param mixed $row
71
     */
72
    public function offsetSet($offset, $row)
73
    {
74
        $model = models($this->model->getClass());
0 ignored issues
show
Bug introduced by
The method getClass() 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

74
        $model = models($this->model->/** @scrutinizer ignore-call */ getClass());
Loading history...
75
76
        if (method_exists($model, 'rebuildRow')) {
77
            $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

77
            /** @scrutinizer ignore-call */ 
78
            $row = $model->rebuildRow($row);
Loading history...
78
        }
79
80
        $hideColumns = [];
81
82
        // Visible Columns
83
        if (count($model->visibleColumns)) {
0 ignored issues
show
Bug introduced by
It seems like $model->visibleColumns can also be of type boolean; however, parameter $var of count() does only seem to accept Countable|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

83
        if (count(/** @scrutinizer ignore-type */ $model->visibleColumns)) {
Loading history...
Bug Best Practice introduced by
The property visibleColumns does not exist on O2System\Framework\Containers\Models. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property visibleColumns does not exist on O2System\Framework\Models\NoSql\Model. Since you implemented __get, consider adding a @property annotation.
Loading history...
84
            $hideColumns = array_diff($row->getColumns(), $model->visibleColumns);
0 ignored issues
show
Bug introduced by
It seems like $model->visibleColumns can also be of type boolean; however, parameter $array2 of array_diff() does only seem to accept 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

84
            $hideColumns = array_diff($row->getColumns(), /** @scrutinizer ignore-type */ $model->visibleColumns);
Loading history...
85
        }
86
87
        // Hide Columns
88
        if (count($model->hideColumns)) {
0 ignored issues
show
Bug Best Practice introduced by
The property hideColumns does not exist on O2System\Framework\Containers\Models. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property hideColumns does not exist on O2System\Framework\Models\NoSql\Model. Since you implemented __get, consider adding a @property annotation.
Loading history...
89
            $hideColumns = array_merge($model->hideColumns);
0 ignored issues
show
Bug introduced by
It seems like $model->hideColumns can also be of type boolean; however, parameter $array1 of array_merge() does only seem to accept 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

89
            $hideColumns = array_merge(/** @scrutinizer ignore-type */ $model->hideColumns);
Loading history...
90
        }
91
92
        // Unset Columns
93
        foreach ($hideColumns as $column) {
94
            $row->offsetUnset($column);
95
        }
96
97
        parent::offsetSet($offset, new Result\Row($row, $model));
0 ignored issues
show
Bug introduced by
It seems like $model can also be of type O2System\Framework\Containers\Models and O2System\Framework\Models\NoSql\Model; however, parameter $model of O2System\Framework\Model...sult\Row::__construct() does only seem to accept O2System\Framework\Models\Sql\Model, 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

97
        parent::offsetSet($offset, new Result\Row($row, /** @scrutinizer ignore-type */ $model));
Loading history...
98
    }
99
100
    // ------------------------------------------------------------------------
101
102
    /**
103
     * Result::pagination
104
     *
105
     * @return \O2System\Framework\Libraries\Ui\Components\Pagination
106
     */
107
    public function pagination()
108
    {
109
        $rows = $this->info->num_rows;
0 ignored issues
show
Bug introduced by
The property num_rows does not seem to exist on O2System\Database\DataObjects\Result\Info.
Loading history...
110
        $rows = empty($rows) ? 0 : $rows;
111
112
        $limit = input()->get('limit');
113
        $limit = empty($limit) ? $this->info->limit : $limit;
114
115
        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

115
        return new Pagination($rows, /** @scrutinizer ignore-type */ $limit);
Loading history...
116
    }
117
}