Completed
Push — dev ( 917cb5...992eab )
by Marc
10:46
created

GuessableRelation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A modelHasMethod() 0 3 1
A guessRelatedMethod() 0 3 1
A guessModel() 0 10 3
1
<?php namespace Mascame\Artificer\Fields;
2
3
use Illuminate\Support\Str;
4
use Mascame\Artificer\Artificer;
5
6
trait GuessableRelation
7
{
8
    protected function modelHasMethod($method) {
9
        return method_exists(Artificer::getModel()->model, $method);
10
    }
11
12
    public function guessRelatedMethod() {
13
        return null;
14
    }
15
16
    public function guessModel() {
17
        $method = $this->guessRelatedMethod();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $method is correct as $this->guessRelatedMethod() (which targets Mascame\Artificer\Fields...n::guessRelatedMethod()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
18
        $modelName = Str::studly($method);
19
20
        if ($method && isset(Artificer::getModel()->models[$modelName])) {
21
            return $modelName;
22
        }
23
24
        return null;
25
    }
26
}