| Total Complexity | 5 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class Filesystem implements FilesystemInterface |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var \drupol\phpvfs\Node\DirectoryInterface |
||
| 18 | */ |
||
| 19 | private $cwd; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Filesystem constructor. |
||
| 23 | * |
||
| 24 | * @param string $id |
||
| 25 | * @param array $attributes |
||
| 26 | * |
||
| 27 | * @throws \Exception |
||
| 28 | */ |
||
| 29 | 11 | public function __construct( |
|
| 30 | string $id, |
||
| 31 | array $attributes = [] |
||
| 32 | ) { |
||
| 33 | $attributes = [ |
||
| 34 | 11 | 'id' => $id, |
|
| 35 | 11 | 'vfs' => $this, |
|
| 36 | 11 | ] + $attributes; |
|
| 37 | |||
| 38 | 11 | $this->cwd = Directory::create($id, $attributes); |
|
| 39 | 11 | } |
|
| 40 | |||
| 41 | /** |
||
| 42 | * {@inheritdoc} |
||
| 43 | */ |
||
| 44 | 1 | public static function create(string $id, array $attributes = []) |
|
| 45 | { |
||
| 46 | 1 | return new self($id, $attributes); |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | 9 | public function getCwd(): DirectoryInterface |
|
| 53 | { |
||
| 54 | 9 | return $this->cwd; |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * {@inheritdoc} |
||
| 59 | */ |
||
| 60 | 2 | public function root(): FilesystemNodeInterface |
|
| 61 | { |
||
| 62 | 2 | return $this->cwd->root(); |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * {@inheritdoc} |
||
| 67 | */ |
||
| 68 | 1 | public function setCwd(DirectoryInterface $dir) |
|
| 73 | } |
||
| 74 | } |
||
| 75 |