BBCode::doSize PHP Method

doSize() public method

Perform formatting against a string for the size tag.
public doSize ( Nbbc\BBCode $bbcode, integer $action, string $name, string $default, array $params, string $content ) : string
$bbcode Nbbc\BBCode Instance of Nbbc doing the parsing.
$action integer Value of one of NBBC's defined constants. Typically, this will be BBCODE_CHECK.
$name string Name of the tag.
$default string Value of the _default parameter, from the $params array.
$params array A standard set parameters related to the tag.
$content string Value between the open and close tags, if any.
return string Formatted value.
    public function doSize($bbcode, $action, $name, $default, $params, $content)
    {
        // px and em are invalid modifiers for this value. Lose 'em.
        $default = preg_replace('/(px|em)/i', '', $default);
        $sizeMap = ['0' => '.5em', '1' => '.67em', '2' => '.83em', '3' => '1.0em', '4' => '1.17em', '5' => '1.5em', '6' => '2.0em', '7' => '2.5em'];
        $size = array_key_exists($default, $sizeMap) ? $sizeMap[$default] : '1.0em';
        return "<span style=\"font-size:{$size}\">{$content}</span>";
    }