Passed
Pull Request — main (#123)
by Andrey
58:10 queued 43:14
created

Path::vendor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
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
14 43
    public function filename(string $filename): string
15
    {
16 43
        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
    }
18 43
19 43
    public function extension(string $filename): string
20
    {
21
        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 14
    }
23
24
    public function vendor(string $path): string
25 43
    {
26
        $vendor = ConfigSupport::vendor();
27 43
28
        return $this->clean($vendor, $path);
29 43
    }
30
31 43
    protected function clean(...$values): string
32
    {
33 43
        foreach ($values as &$value) {
34
            $value = trim($value, " \t\n\r\0\x0B\\/");
35
        }
36 30
37
        return implode('/', $values);
38 30
    }
39
}
40