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