Passed
Push — master ( a3a054...93611a )
by Pol
02:16
created

Inspect   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 32
ccs 11
cts 12
cp 0.9167
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A exec() 0 22 5
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\phpvfs\Commands;
6
7
use drupol\phpvfs\Filesystem\FilesystemInterface;
8
use drupol\phpvfs\Utils\Path;
9
10
class Inspect
11
{
12
    /**
13
     * @param \drupol\phpvfs\Filesystem\FilesystemInterface $vfs
14
     * @param string $id
15
     *
16
     * @throws \Exception
17
     *
18
     * @return string
19
     */
20 1
    public static function exec(FilesystemInterface $vfs, string $id)
21
    {
22 1
        $path = Path::fromString($id);
23
24
        /** @var \drupol\phpvfs\Node\DirectoryInterface $cwd */
25 1
        $cwd = $path->isAbsolute() ?
26 1
            $vfs->getCwd()->root() :
27 1
            $vfs->getCwd();
28
29 1
        foreach ($path->getIterator() as $pathPart) {
30 1
            if (null !== $child = $cwd->containsAttributeId($pathPart)) {
31 1
                $cwd = $child;
32
            } else {
33 1
                throw new \Exception('Unknown path.');
34
            }
35
        }
36
37 1
        if (null === $cwd) {
0 ignored issues
show
introduced by
The condition null === $cwd is always false.
Loading history...
38
            throw new \Exception('TODO');
39
        }
40
41 1
        return \get_class($cwd);
42
    }
43
}
44