src/TwbBundle/View/Helper/TwbBundleBadge.php
public function render($sBadgeMessage, array $aBadgeAttributes = null)
    {
        if (!is_scalar($sBadgeMessage)) {
            throw new InvalidArgumentException(sprintf(
                'Badge message expects a scalar value, "%s" given',
                is_object($sBadgeMessage) ? get_class($sBadgeMessage) : gettype($sBadgeMessage)
            ));
        }

        if (empty($aBadgeAttributes)) {
            $aBadgeAttributes = array('class' => 'badge');
        } else {
            if (empty($aBadgeAttributes['class'])) {
                $aBadgeAttributes['class'] = 'badge';
            } elseif (!preg_match('/(\s|^)badge(\s|$)/', $aBadgeAttributes['class'])) {
                $aBadgeAttributes['class'] .= ' badge';
            }
        }

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

        return sprintf(
            static::$badgeFormat,
            $this->createAttributesString($aBadgeAttributes),
            $sBadgeMessage
        );
    }
public function render($sBadgeMessage, array $aBadgeAttributes = null)
    {
        if (!is_scalar($sBadgeMessage)) {
            throw new InvalidArgumentException(sprintf(
                'Badge message expects a scalar value, "%s" given',
                is_object($sBadgeMessage) ? get_class($sBadgeMessage) : gettype($sBadgeMessage)
            ));
        }

        if (empty($aBadgeAttributes)) {
            $aBadgeAttributes = array('class' => 'badge');
        } else {
            if (empty($aBadgeAttributes['class'])) {
                $aBadgeAttributes['class'] = 'badge';
            } elseif (!preg_match('/(\s|^)badge(\s|$)/', $aBadgeAttributes['class'])) {
                $aBadgeAttributes['class'] .= ' badge';
            }
        }

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

        return sprintf(
            static::$badgeFormat,
            $this->createAttributesString($aBadgeAttributes),
            $sBadgeMessage
        );
    }
Retrieve badge markup
@param string $sBadgeMessage
@param  array $aBadgeAttributes : [optionnal]
@throws InvalidArgumentException
@return string