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.

BelongsTo   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addConstraints() 0 9 2
A addEagerConstraints() 0 9 1
1
<?php
2
3
namespace duxet\Rethinkdb\Eloquent\Relations;
4
5
class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
6
{
7
    /**
8
     * Set the base constraints on the relation query.
9
     *
10
     * @return void
11
     */
12
    public function addConstraints()
13
    {
14
        if (static::$constraints) {
15
            // For belongs to relationships, which are essentially the inverse of has one
16
            // or has many relationships, we need to actually query on the primary key
17
            // of the related models matching on the foreign key that's on a parent.
18
            $this->query->where($this->otherKey, '=', $this->parent->{$this->foreignKey});
19
        }
20
    }
21
22
    /**
23
     * Set the constraints for an eager load of the relation.
24
     *
25
     * @param array $models
26
     *
27
     * @return void
28
     */
29
    public function addEagerConstraints(array $models)
30
    {
31
        // We'll grab the primary key name of the related models since it could be set to
32
        // a non-standard name and not "id". We will then construct the constraint for
33
        // our eagerly loading query so it returns the proper models from execution.
34
        $key = $this->otherKey;
35
36
        $this->query->whereIn($key, $this->getEagerModelKeys($models));
37
    }
38
}
39