1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helldar\LaravelLangPublisher\Support; |
4
|
|
|
|
5
|
|
|
use Helldar\LaravelLangPublisher\Contracts\Path as PathContract; |
|
|
|
|
6
|
|
|
use Helldar\LaravelLangPublisher\Facades\Config as ConfigFacade; |
7
|
|
|
|
8
|
|
|
final class PathJson implements PathContract |
9
|
|
|
{ |
10
|
|
|
protected $extension = '.json'; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Returns a direct link to the folder with the source localization files. |
14
|
|
|
* |
15
|
|
|
* If the file name is specified, a full link to the file will be returned, |
16
|
|
|
* otherwise a direct link to the folder. |
17
|
|
|
* |
18
|
|
|
* @param string|null $locale |
19
|
|
|
* @param string|null $filename |
20
|
|
|
* |
21
|
|
|
* @return string |
22
|
|
|
*/ |
23
|
|
|
public function source(string $locale = null, string $filename = null): string |
24
|
|
|
{ |
25
|
|
|
$locale = $this->getPathForEnglish($locale); |
|
|
|
|
26
|
|
|
$locale = $this->clean($locale); |
27
|
|
|
|
28
|
|
|
return $this->real( |
29
|
|
|
ConfigFacade::getVendorPath() . '/../json' . $locale . $this->extension |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Returns the direct link to the localization folder or, |
35
|
|
|
* if the file name is specified, a link to the localization file. |
36
|
|
|
* |
37
|
|
|
* If the file name or localization is not specified, |
38
|
|
|
* the link to the shared folder of all localizations will be returned. |
39
|
|
|
* |
40
|
|
|
* @param string|null $locale |
41
|
|
|
* @param string|null $filename |
42
|
|
|
* |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
|
|
public function target(string $locale = null, string $filename = null): string |
46
|
|
|
{ |
47
|
|
|
dd('qqq'); |
48
|
|
|
$locale = $this->clean($locale); |
49
|
|
|
|
50
|
|
|
return resource_path(self::LANG . $locale . $this->extension); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
protected function real(string $path): string |
54
|
|
|
{ |
55
|
|
|
return realpath($path); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function clean(string $path = null): ?string |
59
|
|
|
{ |
60
|
|
|
return $path |
61
|
|
|
? self::DIVIDER . ltrim($path, self::DIVIDER) |
62
|
|
|
: $path; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
protected function getPathForEnglish(string $locale): string |
66
|
|
|
{ |
67
|
|
|
return $locale === 'en' |
68
|
|
|
? '../script/en' |
69
|
|
|
: $locale; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths