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.

JoinerFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 9 2
1
<?php
2
3
namespace Sofa\Eloquence\Relations;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
7
use Illuminate\Database\Query\Builder;
8
use Sofa\Eloquence\Contracts\Relations\JoinerFactory as FactoryContract;
9
10
class JoinerFactory implements FactoryContract
11
{
12
    /**
13
     * Create new joiner instance.
14
     *
15
     * @param EloquentBuilder|Builder $query
16
     * @param Model $model
17
     * @return Joiner
18
     */
19
    public static function make($query, Model $model = null)
20
    {
21
        if ($query instanceof EloquentBuilder) {
22
            $model = $query->getModel();
23
            $query = $query->getQuery();
24
        }
25
26
        return new Joiner($query, $model);
0 ignored issues
show
Bug introduced by
It seems like $model can also be of type null or object<Illuminate\Database\Eloquent\Builder>; however, Sofa\Eloquence\Relations\Joiner::__construct() does only seem to accept object<Illuminate\Database\Eloquent\Model>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
27
    }
28
}
29