FileName   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 9
dl 0
loc 31
c 0
b 0
f 0
ccs 15
cts 15
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A isReadable() 0 2 1
A isFile() 0 2 1
A getMimeType() 0 2 1
A __construct() 0 2 1
A getName() 0 2 1
A exists() 0 2 1
A asString() 0 2 1
1
<?php declare(strict_types = 1);
2
namespace Templado\Engine;
3
4
class FileName {
5
6
    /** @var string */
7
    private $path;
8
9 27
    public function __construct(string $path) {
10 27
        $this->path = $path;
11 27
    }
12
13 3
    public function asString(): string {
14 3
        return $this->path;
15
    }
16
17 3
    public function getMimeType(): string {
18 3
        return \mime_content_type($this->path);
19
    }
20
21 3
    public function getName(): string {
22 3
        return \pathinfo($this->path, \PATHINFO_FILENAME);
0 ignored issues
show
Bug Best Practice introduced by Arne Blankerts
The expression return pathinfo($this->path, PATHINFO_FILENAME) could return the type array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
23
    }
24
25 6
    public function exists(): bool {
26 6
        return \file_exists($this->path);
27
    }
28
29 6
    public function isFile(): bool {
30 6
        return \is_file(\realpath($this->path));
31
    }
32
33 6
    public function isReadable(): bool {
34 6
        return \is_readable($this->path);
35
    }
36
}
37