| Total Complexity | 5 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class WatermarkFilter extends FFMpegWatermarkFilter |
||
| 8 | { |
||
| 9 | protected $path; |
||
| 10 | |||
| 11 | public function __construct($watermarkPath, array $coordinates = [], $priority = 0) |
||
| 12 | { |
||
| 13 | parent::__construct($watermarkPath, $coordinates, $priority); |
||
| 14 | |||
| 15 | $this->path = $watermarkPath; |
||
| 16 | } |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Gets the commands from the base filter and normalizes the path. |
||
| 20 | * |
||
| 21 | * @return array |
||
| 22 | */ |
||
| 23 | protected function getCommands() |
||
| 24 | { |
||
| 25 | $commands = parent::getCommands(); |
||
| 26 | |||
| 27 | $commands[1] = str_replace($this->path, static::normalizePath($this->path), $commands[1]); |
||
| 28 | |||
| 29 | return $commands; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Normalizes the path when running on Windows. |
||
| 34 | * |
||
| 35 | * @param string $path |
||
| 36 | * @return string |
||
| 37 | */ |
||
| 38 | public static function normalizePath(string $path): string |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Replaces the slashes and escapes the colon. For some |
||
| 47 | * reason, this filter doesn't work on Windows with |
||
| 48 | * absolute paths that contain forward slashes. |
||
| 49 | * |
||
| 50 | * @param string $path |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | public static function normalizeWindowsPath(string $path): string |
||
| 60 | } |
||
| 61 | } |
||
| 62 |