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 ( 86dce3...98cf71 )
by Nur
02:40
created

HasOne   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B getResult() 0 36 8
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 HasOne
23
 *
24
 * @package O2System\Reactor\Models\Sql\Relations
25
 */
26
class HasOne extends Sql\Relations\Abstracts\AbstractRelation
27
{
28
    /**
29
     * Get Result
30
     *
31
     * @return null
32
     */
33
    public function getResult()
34
    {
35
        if ($this->map->referenceModel->row instanceof Sql\DataObjects\Result\Row) {
0 ignored issues
show
Bug introduced by
The property referenceModel does not exist on O2System\Reactor\Models\...tions\Maps\Intermediary. Did you mean referenceTable?
Loading history...
introduced by
$this->map->referenceModel->row is always a sub-type of O2System\Reactor\Models\Sql\DataObjects\Result\Row.
Loading history...
36
37
            $criteria = $this->map->referenceModel->row->offsetGet($this->map->referenceModel->primaryKey);
38
            $conditions = [$this->map->relationForeignKey => $criteria];
0 ignored issues
show
Bug introduced by
The property relationForeignKey does not seem to exist on O2System\Reactor\Models\...tions\Maps\Intermediary.
Loading history...
39
40
            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...
41
                $result = $this->map->relationModel->qb
42
                    ->from($this->map->relationTable)
43
                    ->getWhere($conditions, 1);
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
                        $this->map->relationModel->result = new Sql\DataObjects\Result($result,
48
                            $this->map->relationModel);
49
50
                        return $this->map->relationModel->row = $this->map->relationModel->result->first();
51
                    }
52
                }
53
            } elseif ( ! empty($this->map->relationTable)) {
54
                $result = $this->map->referenceModel->qb
55
                    ->from($this->map->relationTable)
56
                    ->getWhere($conditions, 1);
57
58
                if ($result instanceof Result) {
59
                    if ($result->count() > 0) {
60
                        $result = new Sql\DataObjects\Result($result, $this->map->referenceModel);
61
62
                        return $result->first();
63
                    }
64
                }
65
            }
66
        }
67
68
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type null.
Loading history...
69
    }
70
}