FieldRelation::getShow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Mascame\Artificer\Fields;
2
3
class FieldRelation
4
{
5
6
    public $relation = false;
7
    protected $options = array();
8
9
10
    public function __construct($relation, $options)
11
    {
12
        $this->relation = ($relation || $this->getType()) ? true : false;
13
        $this->options = $options;
14
    }
15
16
    /**
17
     * @return bool
18
     */
19
    public function isRelation()
20
    {
21
        return $this->relation;
22
    }
23
24
    public function getMethod()
25
    {
26
        return $this->getAttribute('method');
27
    }
28
29
    public function getRelatedModel()
30
    {
31
        return $this->getAttribute('model');
32
    }
33
34
    public function getType()
35
    {
36
        return $this->getAttribute('type');
37
    }
38
39
    public function getForeignKey()
40
    {
41
        return $this->getAttribute('foreign');
42
    }
43
44
    public function getShow()
45
    {
46
        return $this->getAttribute('show');
47
    }
48
49
    /**
50
     * @param string $attribute
51
     */
52
    public function getAttribute($attribute)
53
    {
54
        return isset($this->options[$attribute]) ? $this->options[$attribute] : false;
55
    }
56
}