Php   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 41
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A target() 0 6 1
A source() 0 8 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support\Path;
4
5
use Helldar\LaravelLangPublisher\Facades\Config;
6
7
final class Php extends BasePath
8
{
9
    /**
10
     * Returns a direct link to the folder with the source localization files.
11
     *
12
     * If the file name is specified, a full link to the file will be returned,
13
     * otherwise a direct link to the folder.
14
     *
15
     * @param  string|null  $locale
16
     *
17
     * @return string
18
     */
19
    public function source(string $locale = null): string
20 48
    {
21
        $locale = $this->clean(
22 48
            $this->getPathForEnglish($locale)
0 ignored issues
show
Bug introduced by
It seems like $locale can also be of type null; however, parameter $locale of Helldar\LaravelLangPubli...th::getPathForEnglish() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

22
            $this->getPathForEnglish(/** @scrutinizer ignore-type */ $locale)
Loading history...
23 48
        );
24 48
25
        return $this->real(
26 48
            Config::getVendorPath() . $locale
27 48
        );
28
    }
29
30
    /**
31
     * Returns the direct link to the localization folder or,
32
     * if the file name is specified, a link to the localization file.
33
     *
34
     * If the file name or localization is not specified,
35
     * the link to the shared folder of all localizations will be returned.
36
     *
37
     * @param  string|null  $locale
38
     * @param  string|null  $filename
39
     *
40
     * @return string
41
     */
42
    public function target(string $locale = null, string $filename = null): string
43 48
    {
44
        $locale   = $this->clean($locale);
45 48
        $filename = $this->clean($filename);
46 48
47
        return resource_path(self::LANG . $locale . $filename);
48 48
    }
49
}
50