| Total Complexity | 6 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 92.86% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class Filesystem implements FilesystemInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var \drupol\phpvfs\Node\DirectoryInterface |
||
| 16 | */ |
||
| 17 | private $cwd; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Filesystem constructor. |
||
| 21 | * |
||
| 22 | * @param \drupol\phpvfs\Node\DirectoryInterface $directory |
||
| 23 | */ |
||
| 24 | 16 | public function __construct(DirectoryInterface $directory) |
|
| 25 | { |
||
| 26 | 16 | $this->cwd = $directory; |
|
| 27 | 16 | } |
|
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | 14 | public function getCwd(): DirectoryInterface |
|
| 33 | { |
||
| 34 | 14 | return $this->cwd; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | 4 | public function pwd(): string |
|
| 41 | { |
||
| 42 | 4 | return $this->getCwd()->getPath()->__toString(); |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * {@inheritdoc} |
||
| 47 | */ |
||
| 48 | 2 | public function root(): DirectoryInterface |
|
| 49 | { |
||
| 50 | 2 | if (($root = $this->getCwd()->root()) instanceof DirectoryInterface) { |
|
| 51 | 2 | return $root; |
|
| 52 | } |
||
| 53 | |||
| 54 | throw new \Exception('Unable to get root directory.'); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * {@inheritdoc} |
||
| 59 | */ |
||
| 60 | 2 | public function setCwd(DirectoryInterface $dir) |
|
| 65 | } |
||
| 66 | } |
||
| 67 |