Passed
Push — master ( eb0fcb...47bdab )
by Gabriel
04:01 queued 10s
created

HasRendererTrait::getRenderer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Nip\Form\Elements\Traits;
4
5
/**
6
 * Trait HasRendererTrait
7
 * @package Nip\Form\Elements\Traits
8
 */
9
trait HasRendererTrait
10
{
11
    protected $_isRendered = false;
12
13
    /**
14
     * @param boolean $isRendered
15
     * @return $this
16
     */
17 6
    public function setRendered($isRendered)
18
    {
19 6
        $this->_isRendered = (bool)$isRendered;
20
21 6
        return $this;
22
    }
23
24
    /**
25
     * @return bool
26
     */
27 1
    public function isRendered()
28
    {
29 1
        return (bool)$this->_isRendered;
30
    }
31
32
    /**
33
     * @return bool
34
     */
35 1
    public function hasCustomRenderer()
36
    {
37 1
        return false;
38
    }
39
40
    /**
41
     * @return mixed
42
     */
43 4
    public function render()
44
    {
45 4
        return $this->getRenderer()->render($this);
46
    }
47
48
    /**
49
     * @return mixed
50
     */
51 5
    public function getRenderer()
52
    {
53 5
        return $this->getForm()->getRenderer()->getElementRenderer($this);
0 ignored issues
show
Bug introduced by
It seems like getForm() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        return $this->/** @scrutinizer ignore-call */ getForm()->getRenderer()->getElementRenderer($this);
Loading history...
54
    }
55
56
    /**
57
     * @return mixed
58
     */
59 1
    public function renderElement()
60
    {
61 1
        return $this->getRenderer()->renderElement($this);
62
    }
63
64
    /**
65
     * @return mixed
66
     */
67 1
    public function renderErrors()
68
    {
69 1
        return $this->getRenderer()->renderErrors($this);
70
    }
71
}
72