Passed
Pull Request — main (#123)
by Andrey
58:10 queued 43:14
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
ccs 11
cts 11
cp 1
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A basename() 0 3 1
A clean() 0 7 2
A extension() 0 3 1
A filename() 0 3 1
A vendor() 0 5 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
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