src/TwbBundle/View/Helper/TwbBundleFontAwesome.php
public function render($sFontAwesome, array $aFontAwesomeAttributes = null)
    {
        if (!is_scalar($sFontAwesome)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'FontAwesome expects a scalar value, "%s" given',
                    gettype($sFontAwesome)
                )
            );
        }

        if (empty($aFontAwesomeAttributes)) {
            $aFontAwesomeAttributes = array('class' => 'fa');
        } else {

            if (empty($aFontAwesomeAttributes['class'])) {
                $aFontAwesomeAttributes['class'] = 'fa';
            } elseif (!preg_match('/(\s|^)fa(\s|$)/', $aFontAwesomeAttributes['class'])) {
                $aFontAwesomeAttributes['class'] .= ' fa';
            }
        }

        if (strpos('fa-', $sFontAwesome) !== 0) {
            $sFontAwesome = 'fa-' . $sFontAwesome;
        }

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

        return sprintf(
            static::$faFormat,
            $this->createAttributesString($aFontAwesomeAttributes)
        );
    }
public function render($sFontAwesome, array $aFontAwesomeAttributes = null)
    {
        if (!is_scalar($sFontAwesome)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'FontAwesome expects a scalar value, "%s" given',
                    gettype($sFontAwesome)
                )
            );
        }

        if (empty($aFontAwesomeAttributes)) {
            $aFontAwesomeAttributes = array('class' => 'fa');
        } else {

            if (empty($aFontAwesomeAttributes['class'])) {
                $aFontAwesomeAttributes['class'] = 'fa';
            } elseif (!preg_match('/(\s|^)fa(\s|$)/', $aFontAwesomeAttributes['class'])) {
                $aFontAwesomeAttributes['class'] .= ' fa';
            }
        }

        if (strpos('fa-', $sFontAwesome) !== 0) {
            $sFontAwesome = 'fa-' . $sFontAwesome;
        }

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

        return sprintf(
            static::$faFormat,
            $this->createAttributesString($aFontAwesomeAttributes)
        );
    }
Retrieve fontAwesome markup
@param string $sFontAwesome
@param  array $aFontAwesomeAttributes : [optionnal]
@throws InvalidArgumentException
@return string