You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
702 B

3 years ago
3 years ago
3 years ago
3 years ago
  1. <?php namespace Wpstudio\AssetsManifest\Classes;
  2. class ManifestReader
  3. {
  4. private $manifest = null;
  5. /**
  6. * @param string $manifestPath
  7. * @throws AssetsManifestException
  8. */
  9. public function __construct(string $manifestPath)
  10. {
  11. if (!file_exists($manifestPath)) {
  12. throw new AssetsManifestException('Not found: ' . $manifestPath);
  13. }
  14. if (!is_readable($manifestPath)) {
  15. throw new AssetsManifestException('Not readable: ' . $manifestPath);
  16. }
  17. $this->manifest = json_decode(file_get_contents($manifestPath));
  18. }
  19. public function get(string $assetName)
  20. {
  21. return $this->manifest->$assetName;
  22. }
  23. }