23 lines
599 B
PHP
23 lines
599 B
PHP
<?php
|
|
|
|
namespace Modules\Stylist\Theme;
|
|
|
|
use Illuminate\Filesystem\Filesystem;
|
|
use Modules\Stylist\Theme\Exceptions\ThemeJsonNotFoundException;
|
|
|
|
final class Json
|
|
{
|
|
public function __construct(private readonly Filesystem $files) {}
|
|
|
|
public function read(string $path): array
|
|
{
|
|
$manifest = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'theme.json';
|
|
|
|
if (! $this->files->exists($manifest)) {
|
|
throw ThemeJsonNotFoundException::forPath($path);
|
|
}
|
|
|
|
return json_decode($this->files->get($manifest), true, flags: JSON_THROW_ON_ERROR);
|
|
}
|
|
}
|