Exemple #1
0
 /**
  * Constructor.
  * @param string $text
  * @throws Exceptions\ExtensionException
  * @throws \BadMethodCallException
  * @throws Exceptions\FileException
  */
 public function __construct($text = '')
 {
     if (extension_loaded('gd') === FALSE) {
         throw new Exceptions\ExtensionException('PHP extension GD is not loaded.');
     }
     if (is_string($text) === FALSE) {
         throw new \BadMethodCallException('Parameter "text" must be string.');
     }
     $this->text = $text;
     $this->fontPath = __DIR__ . '/../fonts/open-sans/OpenSans-Regular.ttf';
     if (is_readable($this->fontPath) === FALSE) {
         throw new Exceptions\FileException('Directory with fonts "' . $this->fontPath . '" does not exist or is not readable.');
     }
     $this->setBackgroundColor(Objects\Color::create('white'));
     $this->setTextColor(Objects\Color::create('black'));
     $this->setBorderColor(Objects\Color::create('grey'));
 }