Passed
Push — master ( f58784...79a73a )
by Gabriel
14:23
created

Nip_Form_Renderer_Button_Abstract::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
use Nip\Form\Buttons\AbstractButton;
4
use Nip\Form\Renderer\AbstractRenderer;
5
use Nip\Form\Renderer\Traits\HasAttribsTrait;
6
7
/**
8
 * Class Nip_Form_Renderer_Button_Abstract
9
 */
10
abstract class Nip_Form_Renderer_Button_Abstract
11
{
12
    use HasAttribsTrait;
13
14
    protected $_renderer;
15
    protected $_button;
16
17
    /**
18
     * @return AbstractRenderer
19
     */
20 1
    public function getRenderer()
21
    {
22 1
        return $this->_renderer;
23
    }
24 1
25
    /**
26
     * @param AbstractRenderer $renderer
27
     * @return $this
28
     */
29
    public function setRenderer(AbstractRenderer $renderer)
30
    {
31
        $this->_renderer = $renderer;
32
33
        return $this;
34
    }
35
36
    /**
37
     * @param AbstractButton $item
38
     * @return $this
39 1
     */
40
    public function setItem(AbstractButton $item)
41 1
    {
42
        $this->_item = $item;
0 ignored issues
show
Bug Best Practice introduced by
The property _item does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
43 1
44
        return $this;
45
    }
46
47
    /**
48
     * @return AbstractButton
49 1
     */
50
    public function getElement()
51 1
    {
52
        return $this->getItem();
53
    }
54
55
    /**
56
     * @return AbstractButton
57 1
     */
58
    public function getItem()
59 1
    {
60
        return $this->_item;
61
    }
62
63 1
    public function render()
64
    {
65 1
        $return = '';
66 1
        $return .= $this->renderItem();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->renderItem() targeting Nip_Form_Renderer_Button_Abstract::renderItem() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
67
68 1
        return $return;
69
    }
70
71 1
    public function renderItem()
72
    {
73 1
        $return = $this->generateItem();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $return is correct as $this->generateItem() targeting Nip_Form_Renderer_Button_Abstract::generateItem() 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...
74
75 1
        return $return;
76
    }
77
78
    public function generateItem()
79
    {
80
        return;
81
    }
82
}
83