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