Completed
Pull Request — master (#88)
by Johan
03:28
created

loadTranslationsFromContainers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace App\Port\Loader\Loaders;
4
5
use File;
6
use Illuminate\Translation\Translator;
7
8
/**
9
 * Class TranslationsLoaderTrait.
10
 *
11
 * @author  Mahmoud Zalt <[email protected]>
12
 */
13
trait TranslationsLoaderTrait
14
{
15
16
    /**
17
     * loadTranslationsFromContainers
18
     */
19
    public function loadTranslationsFromContainers($containerName)
20
    {
21
        $containerLangDirectory = base_path('app/Containers/' . $containerName . '/Lang');
22
23
        $this->loadTranslations($containerLangDirectory, $containerName);
24
    }
25
26
    /**
27
     * @param $directory
28
     */
29
    private function loadTranslations($directory, string $containerName = '')
30
    {
31
        if (File::isDirectory($directory)) {
32
            app()->make('translator')->addNamespace(camel_case($containerName), $directory);
33
        }
34
    }
35
36
}
37