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
Directory.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\League\Plates\Template; |
| 4 | |
| 5 | use LogicException; |
| 6 | /** |
| 7 | * Default template directory. |
| 8 | */ |
| 9 | class Directory |
| 10 | { |
| 11 | /** |
| 12 | * Template directory path. |
| 13 | * @var string |
| 14 | */ |
| 15 | protected $path; |
| 16 | /** |
| 17 | * Create new Directory instance. |
| 18 | * @param string $path |
| 19 | */ |
| 20 | public function __construct($path = null) |
| 21 | { |
| 22 | $this->set($path); |
| 23 | } |
| 24 | /** |
| 25 | * Set path to templates directory. |
| 26 | * @param string|null $path Pass null to disable the default directory. |
| 27 | * @return Directory |
| 28 | */ |
| 29 | public function set($path) |
| 30 | { |
| 31 | if (!\is_null($path) and !\is_dir($path)) { |
| 32 | throw new LogicException('The specified path "' . $path . '" does not exist.'); |
| 33 | } |
| 34 | $this->path = $path; |
| 35 | return $this; |
| 36 | } |
| 37 | /** |
| 38 | * Get path to templates directory. |
| 39 | * @return string |
| 40 | */ |
| 41 | public function get() |
| 42 | { |
| 43 | return $this->path; |
| 44 | } |
| 45 | } |
| 46 |