BuildTranslationsCacheCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 3
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fire() 0 9 3
1
<?php namespace Modules\Translation\Console;
2
3
use Illuminate\Console\Command;
4
use Illuminate\Foundation\Bus\DispatchesJobs;
5
use Modules\Translation\Repositories\TranslationRepository;
6
7
class BuildTranslationsCacheCommand extends Command
8
{
9
    use DispatchesJobs;
10
11
    protected $name = 'asgard:build:translations';
12
    protected $description = 'Build the translations cache';
13
    /**
14
     * @var
15
     */
16
    private $translation;
17
18
    public function __construct(TranslationRepository $translation)
19
    {
20
        parent::__construct();
21
        $this->translation = $translation;
22
    }
23
24
    public function fire()
25
    {
26
        foreach ($this->translation->all() as $translation) {
27
            foreach (config('laravellocalization.supportedLocales') as $locale => $language) {
28
                $this->translation->findByKeyAndLocale($translation->key, $locale);
29
            }
30
        }
31
        $this->info('All translations were cached.');
32
    }
33
}
34