Passed
Pull Request — 9.x (#103)
by Andrey
57:24 queued 42:28
created

Pathable   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 56
rs 10
c 1
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A pathTarget() 0 5 1
A pathDirectory() 0 5 1
A pathFilename() 0 5 1
A pathLocales() 0 5 1
A pathExtension() 0 5 1
A pathSource() 0 5 1
A pathVendor() 0 5 1
A pathTargetFull() 0 5 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Concerns;
4
5
use Helldar\LaravelLangPublisher\Facades\Config;
6
use Helldar\LaravelLangPublisher\Facades\Path;
7
8
trait Pathable
9
{
10
    protected function pathSource(string $package, string $locale): string
11
    {
12
        $this->log('Retrieving a link to the source directory for the', $package, 'package and the', $locale, 'localization...');
0 ignored issues
show
Bug introduced by
It seems like log() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

12
        $this->/** @scrutinizer ignore-call */ 
13
               log('Retrieving a link to the source directory for the', $package, 'package and the', $locale, 'localization...');
Loading history...
13
14
        return Path::source($package, $locale);
15
    }
16
17
    protected function pathTarget(string $locale, bool $is_json = false): string
18
    {
19
        $this->log('Retrieving a link to the target directory for the', $locale, '(is json:', $is_json, ') localization...');
20
21
        return Path::target($locale, $is_json);
22
    }
23
24
    protected function pathTargetFull(string $locale, ?string $filename): string
25
    {
26
        $this->log('Retrieving a link to the target file for the', $locale, 'localization, filename is ', $filename, '...');
27
28
        return Path::targetFull($locale, $filename);
29
    }
30
31
    protected function pathLocales(string $package, string $locale = null): string
32
    {
33
        $this->log('Getting the path to excluding English localization: ' . $locale);
34
35
        return Path::locales($package, $locale);
36
    }
37
38
    protected function pathVendor(): string
39
    {
40
        $this->log('Getting the vendor path.');
41
42
        return Config::basePath();
43
    }
44
45
    protected function pathDirectory(string $path): string
46
    {
47
        $this->log('Getting directory name from file path:', $path);
48
49
        return Path::directory($path);
50
    }
51
52
    protected function pathFilename(string $path): string
53
    {
54
        $this->log('Getting file name without extension:', $path);
55
56
        return Path::filename($path);
57
    }
58
59
    protected function pathExtension(string $path): string
60
    {
61
        $this->log('Getting file extension:', $path);
62
63
        return Path::extension($path);
64
    }
65
}
66