View file vendor/league/plates/src/Template/Folder.php

File size: 1.83Kb
  1. <?php
  2.  
  3. namespace League\Plates\Template;
  4.  
  5. use LogicException;
  6.  
  7. /**
  8. * A template folder.
  9. */
  10. class Folder
  11. {
  12. /**
  13. * The folder name.
  14. * @var string
  15. */
  16. protected $name;
  17.  
  18. /**
  19. * The folder path.
  20. * @var string
  21. */
  22. protected $path;
  23.  
  24. /**
  25. * The folder fallback status.
  26. * @var boolean
  27. */
  28. protected $fallback;
  29.  
  30. /**
  31. * Create a new Folder instance.
  32. * @param string $name
  33. * @param string $path
  34. * @param boolean $fallback
  35. */
  36. public function __construct($name, $path, $fallback = false)
  37. {
  38. $this->setName($name);
  39. $this->setPath($path);
  40. $this->setFallback($fallback);
  41. }
  42.  
  43. /**
  44. * Set the folder name.
  45. * @param string $name
  46. * @return Folder
  47. */
  48. public function setName($name)
  49. {
  50. $this->name = $name;
  51.  
  52. return $this;
  53. }
  54.  
  55. /**
  56. * Get the folder name.
  57. * @return string
  58. */
  59. public function getName()
  60. {
  61. return $this->name;
  62. }
  63.  
  64. /**
  65. * Set the folder path.
  66. * @param string $path
  67. * @return Folder
  68. */
  69. public function setPath($path)
  70. {
  71. if (!is_dir($path)) {
  72. throw new LogicException('The specified directory path "' . $path . '" does not exist.');
  73. }
  74.  
  75. $this->path = $path;
  76.  
  77. return $this;
  78. }
  79.  
  80. /**
  81. * Get the folder path.
  82. * @return string
  83. */
  84. public function getPath()
  85. {
  86. return $this->path;
  87. }
  88.  
  89. /**
  90. * Set the folder fallback status.
  91. * @param boolean $fallback
  92. * @return Folder
  93. */
  94. public function setFallback($fallback)
  95. {
  96. $this->fallback = $fallback;
  97.  
  98. return $this;
  99. }
  100.  
  101. /**
  102. * Get the folder fallback status.
  103. * @return boolean
  104. */
  105. public function getFallback()
  106. {
  107. return $this->fallback;
  108. }
  109. }