public function calculateWidth(string $text, int $size = null)
    {
        $size = round(($size ?: static::TEXT_SIZE) * 0.75, 1);
        $box = imagettfbbox($size, 0, $this->path, $text);

        return round(abs($box[2] - $box[0]) + static::SHIELD_PADDING_EXTERNAL + static::SHIELD_PADDING_INTERNAL, 1);
    }
public function calculateWidth(string $text, int $size = null)
    {
        $size = round(($size ?: static::TEXT_SIZE) * 0.75, 1);
        $box = imagettfbbox($size, 0, $this->path, $text);

        return round(abs($box[2] - $box[0]) + static::SHIELD_PADDING_EXTERNAL + static::SHIELD_PADDING_INTERNAL, 1);
    }
public function calculateWidth ( string $ text , int $ size = null ) { $ size = round ( ( $ size ? : static :: TEXT_SIZE ) * 0.75 , 1 ) ; $ box = imagettfbbox ( $ size , 0 , $ this -> path , $ text ) ; return round ( abs ( $ box [ 2 ] - $ box [ 0 ] ) + static :: SHIELD_PADDING_EXTERNAL + static :: SHIELD_PADDING_INTERNAL , 1 ) ; }
Calculate the width of the text box.

@param string   $text
@param int|null $size

@return float
Calculate the width of the text box .