Passed
Push — master ( 526326...f9ca3c )
by Gabriel
04:02 queued 11s
created

Nip_Form_Element_Money::setValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
class Nip_Form_Element_Money extends Nip_Form_Element_Input
4
{
5
    protected $_type = 'money';
6
7
    public function init()
8
    {
9
        parent::init();
10
        $this->setAttrib('type', 'number');
11
        $this->setOption('currency', '');
12
    }
13
14
    /**
15
     * @inheritDoc
16
     */
17
    public function setValue($value)
18
    {
19
        if (is_object($value)) {
20
            /** @var \ByTIC\Money\Money $value */
21
            $this->setOption('currency', $value->getCurrency());
22
            $value = $value->formatByDecimal();
23
        }
24
        return parent::setValue($value);
25
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30
    public function getValue($requester = 'abstract')
31
    {
32
        return parent::getValue($requester);
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::getValue($requester) targeting Nip\Form\Utility\HasAttributesTrait::getValue() 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...
33
    }
34
}
35