File indexing completed on 2025-01-26 05:29:13
0001 <?php 0002 0003 namespace Intervention\Image\Commands; 0004 0005 use Closure; 0006 0007 class TextCommand extends \Intervention\Image\Commands\AbstractCommand 0008 { 0009 /** 0010 * Write text on given image 0011 * @param \Intervention\Image\Image $image 0012 * @return boolean 0013 */ 0014 public function execute($image) 0015 { 0016 $text = $this->argument(0)->required()->value(); 0017 $x = $this->argument(1)->type('numeric')->value(0); 0018 $y = $this->argument(2)->type('numeric')->value(0); 0019 $callback = $this->argument(3)->type('closure')->value(); 0020 0021 $fontclassname = sprintf('\Intervention\Image\%s\Font', 0022 $image->getDriver()->getDriverName()); 0023 0024 $font = new $fontclassname($text); 0025 0026 if ($callback instanceof Closure) { 0027 $callback($font); 0028 } 0029 0030 $font->applyToImage($image, $x, $y); 0031 0032 return true; 0033 } 0034 }