Passed
Push — master ( c97482...68f9e3 )
by Andrey
07:00 queued 04:30
created

Php::source()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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
     * @param  string|null  $filename
17
     *
18
     * @return string
19
     */
20 48
    public function source(string $locale = null, string $filename = null): string
21
    {
22 48
        $locale   = $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
        $locale   = $this->getPathForEnglish(/** @scrutinizer ignore-type */ $locale);
Loading history...
23 48
        $locale   = $this->clean($locale);
24 48
        $filename = $this->clean($filename);
25
26 48
        return $this->real(
27 48
            Config::getVendorPath() . $locale . $filename
28
        );
29
    }
30
31
    /**
32
     * Returns the direct link to the localization folder or,
33
     * if the file name is specified, a link to the localization file.
34
     *
35
     * If the file name or localization is not specified,
36
     * the link to the shared folder of all localizations will be returned.
37
     *
38
     * @param  string|null  $locale
39
     * @param  string|null  $filename
40
     *
41
     * @return string
42
     */
43 48
    public function target(string $locale = null, string $filename = null): string
44
    {
45 48
        $locale   = $this->clean($locale);
46 48
        $filename = $this->clean($filename);
47
48 48
        return resource_path(self::LANG . $locale . $filename);
49
    }
50
}
51