Passed
Push — 10.x ( d6d64f...175d11 )
by Andrey
13:22
created

Path   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A basename() 0 3 1
A filename() 0 3 1
A vendor() 0 5 1
A clean() 0 7 2
A extension() 0 3 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support;
4
5
use Helldar\LaravelLangPublisher\Facades\Config as ConfigSupport;
6
7
final class Path
8
{
9
    public function basename(string $filename): string
10
    {
11
        return pathinfo($filename, PATHINFO_BASENAME);
0 ignored issues
show
Bug Best Practice introduced by
The expression return pathinfo($filenam...port\PATHINFO_BASENAME) 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...
12
    }
13 24
14
    public function filename(string $filename): string
15 24
    {
16
        return pathinfo($filename, PATHINFO_FILENAME);
0 ignored issues
show
Bug Best Practice introduced by
The expression return pathinfo($filenam...port\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...
17 24
    }
18 24
19
    public function extension(string $filename): string
20
    {
21 7
        return pathinfo($filename, PATHINFO_EXTENSION);
0 ignored issues
show
Bug Best Practice introduced by
The expression return pathinfo($filenam...ort\PATHINFO_EXTENSION) 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...
22
    }
23
24 24
    public function vendor(string $path): string
25
    {
26 24
        $vendor = ConfigSupport::vendor();
27
28 24
        return $this->clean($vendor, $path);
29
    }
30 24
31
    protected function clean(...$values): string
32 24
    {
33
        foreach ($values as &$value) {
34
            $value = trim($value, " \t\n\r\0\x0B\\/");
35 15
        }
36
37 15
        return implode('/', $values);
38
    }
39
}
40