Modelable::setModel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Blok\Repository\Traits;
4
5
/**
6
 * Trait Modelable helped to handle class that needs to set or get a param based on a model
7
 *
8
 * @package App\Traits
9
 */
10
trait Modelable
11
{
12
    public $model;
13
14
    /**
15
     * Child class should always implements at least a model method and return a class name
16
     *
17
     * @return mixed
18
     */
19
    abstract public function model();
20
21
    public function getModel()
22
    {
23
        return $this->model;
24
    }
25
26
    /**
27
     * @param mixed $model
28
     * @return $this
29
     */
30
    public function setModel($model)
31
    {
32
        $this->model = $model;
33
        return $this;
34
    }
35
36
    /**
37
     * @return \Illuminate\Database\Eloquent\Builder
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Builder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
38
     */
39
    public function makeModel() {
40
41
        $model = $this->app->make($this->model());
42
43
        return $this->model = $model;
44
    }
45
}
46