Passed
Push — master ( 8d5c1a...e21dd3 )
by Pol
02:37
created

Filesystem   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 49
ccs 12
cts 12
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setCwd() 0 5 1
A __construct() 0 3 1
A pwd() 0 3 1
A getCwd() 0 3 1
A root() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\phpvfs\Filesystem;
6
7
use drupol\phpvfs\Node\DirectoryInterface;
8
use drupol\phpvfs\Node\FilesystemNodeInterface;
9
10
/**
11
 * Class Filesystem.
12
 */
13
class Filesystem implements FilesystemInterface
14
{
15
    /**
16
     * @var \drupol\phpvfs\Node\DirectoryInterface
17
     */
18
    private $cwd;
19
20
    /**
21
     * Filesystem constructor.
22
     *
23
     * @param \drupol\phpvfs\Node\DirectoryInterface $directory
24
     */
25 16
    public function __construct(DirectoryInterface $directory)
26
    {
27 16
        $this->cwd = $directory;
28 16
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 14
    public function getCwd(): DirectoryInterface
34
    {
35 14
        return $this->cwd;
36
    }
37
38
    /**
39
     * @return string
40
     */
41 4
    public function pwd(): string
42
    {
43 4
        return $this->getCwd()->getPath()->__toString();
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 2
    public function root(): FilesystemNodeInterface
50
    {
51 2
        return $this->getCwd()->root();
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 2
    public function setCwd(DirectoryInterface $dir)
58
    {
59 2
        $this->cwd = $dir;
60
61 2
        return $this;
62
    }
63
}
64