Completed
Push — dev ( 3b7fd7...78cf07 )
by Marc
02:31
created

Relation::relationModal()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 116
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 9
Bugs 1 Features 1
Metric Value
c 9
b 1
f 1
dl 0
loc 116
rs 8.2857
cc 2
eloc 29
nc 2
nop 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A Relation::hasFilter() 0 4 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace Mascame\Artificer\Fields\Types\Relations;
2
3
use Mascame\Artificer\Artificer;
4
use Mascame\Artificer\Fields\GuessableRelation;
5
use Mascame\Artificer\Fields\Relationable;
6
use Mascame\Artificer\Model\ModelManager;
7
use Mascame\Formality\Field\Field;
8
use Route;
9
use URL;
10
11
class Relation extends Field
12
{
13
    use Relationable, GuessableRelation;
14
15
    /**
16
     * @var ModelManager;
17
     */
18
    public $modelObject;
19
20
    public $relation = true;
21
22
    /**
23
     * @var ModelManager;
24
     */
25
    public $model;
26
    public $fields;
27
    public $createURL;
28
    public $relatedModel;
29
30
    /**
31
     * Relation constructor.
32
     */
33
    public function __construct($name, $value = null, $options = [])
34
    {
35
        parent::__construct($name, $value, $options);
36
37
        $this->modelObject = Artificer::modelManager();
38
    }
39
40
    public function getRelatedInstance() {
41
        return $this->getRelatedModel()['instance'];
42
    }
43
44
    public function editURL($model_route, $id)
45
    {
46
        return URL::route('admin.model.edit', array('slug' => $model_route, 'id' => $id));
47
    }
48
49
    public function createURL($model_route)
50
    {
51
        return URL::route('admin.model.create', array('slug' => $model_route));
52
    }
53
54
    public function hasFilter()
55
    {
56
        return false;
57
    }
58
59
}