Files
assetsmanifest-plugin/classes/ManifestReader.php

29 lines
702 B
PHP
Raw Normal View History

2021-09-13 17:15:33 +03:00
<?php namespace Wpstudio\AssetsManifest\Classes;
class ManifestReader
{
private $manifest = null;
/**
* @param string $manifestPath
* @throws AssetsManifestException
*/
2021-09-13 17:15:33 +03:00
public function __construct(string $manifestPath)
{
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));
}
public function get(string $assetName)
2021-09-13 17:15:33 +03:00
{
return $this->manifest->$assetName;
}
}