oc-resizer-plugin/compressors/Compressor.php

39 lines
774 B
PHP

<?php
namespace Aweos\Resizer\Compressors;
use Storage;
abstract class Compressor
{
abstract function make(string $path): array;
abstract protected function getExtension();
public function tmpPath(): string
{
return "/tmp/".str_slug(microtime());
}
protected function versionFilename(string $source, $width, $height): string
{
return pathinfo($source, PATHINFO_FILENAME).
'-'.
$width.
'x'.
$height.
'.'.$this->getExtension();
}
public function moveTo(string $source, string $destination): void
{
if (Storage::exists($destination)) {
Storage::delete($destination);
}
Storage::move($source, $destination);
}
}