Completed
Push — dev ( 726aeb...0f045d )
by Marc
02:06
created

GuessableRelation::modelHasMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
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
}