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.

HasManyThrough::getResult()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 13
c 1
b 0
f 0
nc 5
nop 0
dl 0
loc 24
rs 9.5222
1
<?php
2
/**
3
 * This file is part of the O2System PHP 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\Reactor\Models\Sql\Relations;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Database\DataObjects\Result;
19
use O2System\Reactor\Models\Sql;
20
21
/**
22
 * Class HasManyThrough
23
 *
24
 * @package O2System\Reactor\Models\Sql\Relations
25
 */
26
class HasManyThrough extends Sql\Relations\Abstracts\AbstractRelation
27
{
28
    /**
29
     * Get Result
30
     *
31
     * @return Sql\DataObjects\Result|bool
32
     */
33
    public function getResult()
34
    {
35
        // print_out($this->map);
36
        if ($this->map->pivotModel->row instanceof Sql\DataObjects\Result\Row) {
0 ignored issues
show
Bug introduced by
The property pivotModel does not seem to exist on O2System\Reactor\Models\Sql\Relations\Maps\Inverse.
Loading history...
Bug introduced by
The property pivotModel does not seem to exist on O2System\Reactor\Models\...elations\Maps\Reference.
Loading history...
Bug introduced by
The property pivotModel does not seem to exist on O2System\Reactor\Models\...tions\Maps\Intermediary.
Loading history...
37
            $result = $this->map->pivotModel->qb
38
                ->from($this->map->relationTable)
39
                ->join($this->map->referenceTable, implode(' = ', [
40
                    $this->map->referencePrimaryKey,
41
                    $this->map->relationForeignKey,
0 ignored issues
show
Bug introduced by
The property relationForeignKey does not seem to exist on O2System\Reactor\Models\...tions\Maps\Intermediary.
Loading history...
42
                ]))
43
                ->getWhere([$this->map->referencePrimaryKey => $this->map->pivotModel->row->offsetGet($this->map->pivotForeignKey)]);
0 ignored issues
show
Bug introduced by
The property pivotForeignKey does not seem to exist on O2System\Reactor\Models\...tions\Maps\Intermediary.
Loading history...
Bug introduced by
The property pivotForeignKey does not seem to exist on O2System\Reactor\Models\Sql\Relations\Maps\Inverse.
Loading history...
Bug introduced by
The property pivotForeignKey does not seem to exist on O2System\Reactor\Models\...elations\Maps\Reference.
Loading history...
44
45
            if ($result instanceof Result) {
0 ignored issues
show
introduced by
$result is always a sub-type of O2System\Database\DataObjects\Result.
Loading history...
46
                if ($result->count() > 0) {
47
                    if ($this->map->relationModel instanceof Sql\Model) {
0 ignored issues
show
introduced by
$this->map->relationModel is always a sub-type of O2System\Reactor\Models\Sql\Model.
Loading history...
48
                        return new Sql\DataObjects\Result($result, $this->map->relationModel);
0 ignored issues
show
Bug Best Practice introduced by
The expression return new O2System\Reac...is->map->relationModel) returns the type O2System\Reactor\Models\Sql\DataObjects\Result which is incompatible with the return type mandated by O2System\Reactor\Models\...ctRelation::getResult() of O2System\Reactor\Models\...esult\Row|array|boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
49
                    }
50
51
                    return new Sql\DataObjects\Result($result, $this->map->pivotModel);
52
                }
53
            }
54
        }
55
56
        return false;
57
    }
58
}