public function wordWrapText($text, $wrapWidth)
    {
        $wrappedText = '';
        foreach (explode(PHP_EOL, $text) as $line) {
            $words = explode(' ', $line);
            $currentLine = array_shift($words);
            while (count($words) > 0) {
                $word = array_shift($words);
                if ($this->getTextWidth($currentLine . ' ' . $word) > $wrapWidth) {
                    $wrappedText .= PHP_EOL . $currentLine;
                    $currentLine = $word;
                } else {
                    $currentLine .= ' ' . $word;
                }
            }
            $wrappedText .= PHP_EOL . $currentLine;
        }
        return ltrim($wrappedText, PHP_EOL);
    }