Total Complexity | 6 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
7 | class TranslationsLoader extends BaseFileLoader |
||
8 | { |
||
9 | /** |
||
10 | * Load the files to load and register them |
||
11 | * |
||
12 | * @param string $module |
||
13 | * @return void |
||
14 | */ |
||
15 | public function loadFiles(string $module): void |
||
16 | { |
||
17 | if (!$this->getFilesToLoad($module)->isEmpty()) { |
||
18 | $this->repo->addTranslation($this->getFilesPath($module), $module); |
||
19 | } |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Retrieve the collection of files found for the given module |
||
24 | * |
||
25 | * @param string $module |
||
26 | * @return \Illuminate\Support\Collection |
||
27 | */ |
||
28 | public function getFilesToLoad(string $module): Collection |
||
29 | { |
||
30 | if (!$this->repo->filesExist($this->getFilesPath($module))) { |
||
31 | return new Collection(); |
||
32 | } |
||
33 | |||
34 | return $this->repo->glob( |
||
35 | $this->getFilesPath($module) . '/**/*.php' |
||
36 | ); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Retrieve the path where the files to load should be at |
||
41 | * |
||
42 | * @param string $module |
||
43 | * @return string |
||
44 | */ |
||
45 | public function getFilesPath(string $module): string |
||
46 | { |
||
47 | return $this->repo->getModulePath($module) . "/resources/lang"; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Retrieve the namespace to be used when registering the files |
||
52 | * |
||
53 | * @param string $module |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getNamespace(string $module): string |
||
60 | } |
||
61 | |||
62 | } |
||
63 |