src/TwbBundle/View/Helper/TwbBundleLabel.php
public function render($sLabelMessage, $aLabelAttributes = 'label-default')
    {
        if (!is_scalar($sLabelMessage)) {
            throw new InvalidArgumentException('Label message expects a scalar value, "' . gettype($sLabelMessage) . '" given');
        }

        if (empty($aLabelAttributes)) {
            throw new InvalidArgumentException('Label attributes are empty');
        }

        if (is_string($aLabelAttributes)) {
            $aLabelAttributes = array('class' => $aLabelAttributes);
        } elseif (!is_array($aLabelAttributes)) {
            throw new InvalidArgumentException('Label attributes expects a string or an array, "' . gettype($aLabelAttributes) . '" given');
        } elseif (empty($aLabelAttributes['class'])) {
            throw new \InvalidArgumentException('Label "class" attribute is empty');
        } elseif (!is_string($aLabelAttributes['class'])) {
            throw new InvalidArgumentException('Label "class" attribute expects string, "' . gettype($aLabelAttributes) . '" given');
        }

        if (!preg_match('/(\s|^)label(\s|$)/', $aLabelAttributes['class'])) {
            $aLabelAttributes['class'] .= ' label';
        }

        if (null !== ($oTranslator = $this->getTranslator())) {
            $sLabelMessage = $oTranslator->translate($sLabelMessage, $this->getTranslatorTextDomain());
        }

        return sprintf(
            static::$labelFormat,
            isset($aLabelAttributes['tagName']) ? $aLabelAttributes['tagName'] : $this->tagName,
            $this->createAttributesString($aLabelAttributes),
            $sLabelMessage
        );
    }
public function render($sLabelMessage, $aLabelAttributes = 'label-default')
    {
        if (!is_scalar($sLabelMessage)) {
            throw new InvalidArgumentException('Label message expects a scalar value, "' . gettype($sLabelMessage) . '" given');
        }

        if (empty($aLabelAttributes)) {
            throw new InvalidArgumentException('Label attributes are empty');
        }

        if (is_string($aLabelAttributes)) {
            $aLabelAttributes = array('class' => $aLabelAttributes);
        } elseif (!is_array($aLabelAttributes)) {
            throw new InvalidArgumentException('Label attributes expects a string or an array, "' . gettype($aLabelAttributes) . '" given');
        } elseif (empty($aLabelAttributes['class'])) {
            throw new \InvalidArgumentException('Label "class" attribute is empty');
        } elseif (!is_string($aLabelAttributes['class'])) {
            throw new InvalidArgumentException('Label "class" attribute expects string, "' . gettype($aLabelAttributes) . '" given');
        }

        if (!preg_match('/(\s|^)label(\s|$)/', $aLabelAttributes['class'])) {
            $aLabelAttributes['class'] .= ' label';
        }

        if (null !== ($oTranslator = $this->getTranslator())) {
            $sLabelMessage = $oTranslator->translate($sLabelMessage, $this->getTranslatorTextDomain());
        }

        return sprintf(
            static::$labelFormat,
            isset($aLabelAttributes['tagName']) ? $aLabelAttributes['tagName'] : $this->tagName,
            $this->createAttributesString($aLabelAttributes),
            $sLabelMessage
        );
    }
Retrieve label markup
@param string $sLabelMessage
@param  string|array $aLabelAttributes : [optionnal] if string, label class
@throws InvalidArgumentException
@return string