AbstractConverter.php
5 months ago
GraphicsDriverConverter.php
5 months ago
ImagickConverter.php
5 months ago
AbstractConverter.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Favicon\Converter; |
| 4 | |
| 5 | /** @internal */ |
| 6 | abstract class AbstractConverter |
| 7 | { |
| 8 | protected string $blob; |
| 9 | protected string $path; |
| 10 | public function __construct(string $blob, string $path) |
| 11 | { |
| 12 | $this->blob = $blob; |
| 13 | $this->path = $path; |
| 14 | } |
| 15 | public abstract function save(); |
| 16 | public static function make(string $blob, string $path) : ?\IAWP\Favicon\Converter\AbstractConverter |
| 17 | { |
| 18 | if (\extension_loaded('imagick')) { |
| 19 | return new \IAWP\Favicon\Converter\ImagickConverter($blob, $path); |
| 20 | } elseif (\extension_loaded('gd')) { |
| 21 | return new \IAWP\Favicon\Converter\GraphicsDriverConverter($blob, $path); |
| 22 | } else { |
| 23 | return null; |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 |