2021-09-13 17:15:33 +03:00
|
|
|
<?php namespace Wpstudio\AssetsManifest\Classes;
|
|
|
|
|
|
|
|
class ManifestReader
|
|
|
|
{
|
|
|
|
private $manifest = null;
|
|
|
|
|
2022-01-09 19:09:18 +03:00
|
|
|
/**
|
|
|
|
* @param string $manifestPath
|
|
|
|
* @throws AssetsManifestException
|
|
|
|
*/
|
2021-09-13 17:15:33 +03:00
|
|
|
public function __construct(string $manifestPath)
|
|
|
|
{
|
2022-01-09 19:09:18 +03:00
|
|
|
if (!file_exists($manifestPath)) {
|
|
|
|
throw new AssetsManifestException('Not found: ' . $manifestPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_readable($manifestPath)) {
|
|
|
|
throw new AssetsManifestException('Not readable: ' . $manifestPath);
|
|
|
|
}
|
|
|
|
|
2021-09-13 17:15:33 +03:00
|
|
|
$this->manifest = json_decode(file_get_contents($manifestPath));
|
|
|
|
}
|
|
|
|
|
2022-01-09 19:09:18 +03:00
|
|
|
public function get(string $assetName)
|
2021-09-13 17:15:33 +03:00
|
|
|
{
|
|
|
|
return $this->manifest->$assetName;
|
|
|
|
}
|
|
|
|
}
|