. */ declare(strict_types=1); namespace SP\Infrastructure\File; use SP\Domain\File\Ports\FileHandlerInterface; use SP\Domain\Storage\Ports\YamlFileStorageService; use Symfony\Component\Yaml\Yaml; /** * Class YamlFileStorage */ final readonly class YamlFileStorage implements YamlFileStorageService { public function __construct(private FileHandlerInterface $fileHandler) { } /** * @inheritDoc */ public function load(): array { return Yaml::parseFile($this->fileHandler->getFile()); } /** * @inheritDoc */ public function save(array $data): YamlFileStorageService { $this->fileHandler->save(Yaml::dump($data, 3, 2, Yaml::DUMP_OBJECT_AS_MAP)); return $this; } /** * @throws FileException */ public function getFileTime(): int { return $this->fileHandler->getFileTime(); } }