Issues (22)

src/Support/Path/Json.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support\Path;
4
5
use Helldar\LaravelLangPublisher\Facades\Config;
6
7
final class Json extends BasePath
8
{
9
    protected $is_json = true;
10
11
    /**
12
     * Returns a direct link to the folder with the source localization files.
13
     *
14
     * If the file name is specified, a full link to the file will be returned,
15
     * otherwise a direct link to the folder.
16
     *
17
     * @param  string|null  $locale
18
     *
19
     * @return string
20
     */
21
    public function source(string $locale = null): string
22 54
    {
23
        $directory = $this->getPathForEnglish($locale);
0 ignored issues
show
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

23
        $directory = $this->getPathForEnglish(/** @scrutinizer ignore-type */ $locale);
Loading history...
24 54
        $locale    = $this->clean($locale);
25 54
26 54
        return $this->real(
27
            Config::getVendorPath() . $directory . $locale . '.json'
28 54
        );
29 54
    }
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
    public function target(string $locale = null, string $filename = null): string
44
    {
45 54
        $locale = $this->clean($locale);
46
47 54
        return resource_path(self::LANG . $locale . '.json');
48 54
    }
49
}
50