. */ namespace SP\Domain\Html\Services; use SP\Domain\File\Ports\FileHandlerInterface; use SP\Domain\Http\Services\Request as HttpRequest; use SP\Infrastructure\File\FileException; /** * Class MinifyFile */ final readonly class MinifyFile { public function __construct( private FileHandlerInterface $fileHandler, private bool $minify ) { } public function getHash(): string { return $this->fileHandler->getHash(); } public function needsMinify(): bool { return $this->minify === true && !preg_match('/\.min|pack\.css|js/', $this->fileHandler->getName()); } public function getName(): string { return HttpRequest::getSecureAppFile($this->fileHandler->getName(), $this->fileHandler->getBase()); } /** * @throws FileException */ public function getContent(): string { return $this->fileHandler->readToString(); } }