for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* YAWIK
*
* @filesource
* @copyright (c) 2013-2016 Cross Solution (http://cross-solution.de)
* @author cbleek
* @license MIT
*/
namespace Core\Form\View\Helper;
use Zend\Form\View\Helper\FormLabel;
use Zend\Form\ElementInterface;
use Zend\Form\Exception;
class RequiredMarkInFormLabel extends FormLabel{
public function __invoke(ElementInterface $element = null, $labelContent = null, $position = null)
{
// Set $required to a default of true | existing elements required-value
$required = ($element->hasAttribute('required') ? true : false);
$element
null
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(); } }
if (true === $required) {
$labelContent = sprintf(
'%s<span class="required-mark">*</span>',
$labelContent
);
}
return $this->openTag() . $labelContent . $this->closeTag();
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: