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

FileSystemPath::exists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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