. */ namespace SP\Domain\Html; use SP\Http\Request as HttpRequest; use SP\Infrastructure\File\FileException; use SP\Infrastructure\File\FileHandlerInterface; /** * Class MinifyFile */ final class MinifyFile { public function __construct( private readonly FileHandlerInterface $fileHandler, private readonly 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(); } }