Completed
Push — develop ( eb5f8c...2537a4 )
by
unknown
13:09
created

RequiredMarkInFormLabel::__invoke()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 3
eloc 7
nc 4
nop 3
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013-2016 Cross Solution (http://cross-solution.de)
7
 * @author cbleek
8
 * @license   MIT
9
 */
10
11
namespace Core\Form\View\Helper;
12
13
14
use Zend\Form\View\Helper\FormLabel;
15
use Zend\Form\ElementInterface;
16
use Zend\Form\Exception;
17
18
class RequiredMarkInFormLabel extends FormLabel{
19
    public function __invoke(ElementInterface $element = null, $labelContent = null, $position = null)
20
    {
21
        // Set $required to a default of true | existing elements required-value
22
        $required = ($element->hasAttribute('required') ? true : false);
0 ignored issues
show
Bug introduced by
It seems like $element is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
23
24
        if (true === $required) {
25
            $labelContent = sprintf(
26
                '%s<span class="required-mark">*</span>',
27
                $labelContent
28
            );
29
        }
30
31
        return $this->openTag() . $labelContent . $this->closeTag();
32
    }
33
}