AbstractReaderYml.php 763 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace ModulesGarden\ProxmoxAddon\Core\SL;
  3. use ModulesGarden\ProxmoxAddon\Core\FileReader\Reader;
  4. /**
  5. * Description of AbstractReaderYml
  6. *
  7. * @author Rafał Ossowski <rafal.os@modulesgarden.com>
  8. */
  9. abstract class AbstractReaderYml
  10. {
  11. /**
  12. * @var array
  13. */
  14. protected $data = [];
  15. public function __construct()
  16. {
  17. if (count($this->data) == 0)
  18. {
  19. $this->load();
  20. }
  21. }
  22. public function getData()
  23. {
  24. return $this->data;
  25. }
  26. protected function readYml($name)
  27. {
  28. return Reader::read($name)->get();
  29. }
  30. public static function get()
  31. {
  32. $instance = new static;
  33. return $instance->getData();
  34. }
  35. abstract protected function load();
  36. }