Completed
Pull Request — master (#13)
by Victor
01:57
created

FileSystemPath   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 72
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A rawPath() 0 4 1
A pathName() 0 4 1
A filename() 0 4 1
A size() 0 4 1
A type() 0 4 1
A exists() 0 4 1
A isDirectory() 0 4 1
1
<?php
2
3
namespace LazyEight\DiTesto\FileSystem;
4
5
use LazyEight\DiTesto\Interfaces\FileSystem\FileSystemPathInterface;
6
7
class FileSystemPath implements FileSystemPathInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $path;
13
14
    /**
15
     * FileSystemPath constructor.
16
     * @param string $path
17
     */
18 1
    public function __construct(string $path)
19
    {
20 1
        $this->path = $path;
21 1
    }
22
23
    /**
24
     * @inheritDoc
25
     */
26 2
    public function rawPath(): string
27
    {
28 2
        return $this->path;
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34 2
    public function pathName(): string
35
    {
36 2
        return dirname($this->path);
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42 2
    public function filename(): string
43
    {
44 2
        return basename($this->path);
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50 2
    public function size(): int
51
    {
52 2
        return filesize($this->path);
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58 2
    public function type(): string
59
    {
60 2
        return mime_content_type($this->path);
61
    }
62
63
    /**
64
     * @inheritDoc
65
     */
66 2
    public function exists(): bool
67
    {
68 2
        return file_exists($this->path);
69
    }
70
71
    /**
72
     * @inheritDoc
73
     */
74 1
    public function isDirectory(): bool
75
    {
76 1
        return is_dir($this->path);
77
    }
78
}
79