91 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Nwb\MultiDownloaderClient;
 | |
| 
 | |
| class ImageEditOptions
 | |
| {
 | |
|     /**
 | |
|      * @var int
 | |
|      */
 | |
|     private $width;
 | |
| 
 | |
|     /**
 | |
|      * @var int
 | |
|      */
 | |
|     private $height;
 | |
| 
 | |
|     /**
 | |
|      * @var Watermark[][]
 | |
|      */
 | |
|     private $watermarks = [];
 | |
| 
 | |
|     public function width(int $width)
 | |
|     {
 | |
|         $this->width = $width;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     public function getWidth(): int
 | |
|     {
 | |
|         return $this->width;
 | |
|     }
 | |
| 
 | |
|     public function height(int $height)
 | |
|     {
 | |
|         $this->height = $height;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     public function getHeight(): int
 | |
|     {
 | |
|         return $this->height;
 | |
|     }
 | |
| 
 | |
|     public function watermarks(array $watermarks)
 | |
|     {
 | |
|         $this->watermarks = [];
 | |
|         $this->addWatermarks($watermarks);
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param array $declinations Tableau de déclinaisons d'une watermark dans plusieurs tailles
 | |
|      */
 | |
|     public function addWatermark(array $declinations)
 | |
|     {
 | |
|         $this->watermarks[] = $declinations;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     public function addWatermarks(array $watermarks)
 | |
|     {
 | |
|         foreach ($watermarks as $watermark) {
 | |
|             $this->addWatermark($watermark);
 | |
|         }
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     public function getWatermarks(): array
 | |
|     {
 | |
|         return $this->watermarks;
 | |
|     }
 | |
| 
 | |
|     public function toArray(): array
 | |
|     {
 | |
|         return array_filter([
 | |
|             'width' => $this->width,
 | |
|             'height' => $this->height,
 | |
|             'watermarks' => array_map(function (array $declinations) {
 | |
|                 return array_map(function (Watermark $watermark) {
 | |
|                     return $watermark->toArray();
 | |
|                 }, $declinations);
 | |
|             }, $this->watermarks),
 | |
|         ]);
 | |
|     }
 | |
| }
 |