Completed
Push — laravel-5 ( 77d56a...dfba7d )
by Andy
02:29
created

RefreshCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 63.64%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 48
ccs 7
cts 11
cp 0.6364
rs 10
c 3
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
A fire() 0 4 1
1
<?php
2
namespace JsLocalization\Console;
3
4
use Config;
5
use Illuminate\Console\Command;
6
use JsLocalization\Exceptions\ConfigException;
7
use JsLocalization\Facades\ConfigCachingService;
8
use JsLocalization\Facades\MessageCachingService;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Input\InputArgument;
11
12
class RefreshCommand extends Command
13
{
14
    /**
15
     * The console command name.
16
     *
17
     * @var string
18
     */
19
    protected $name = 'js-localization:refresh';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = "Refresh message cache after changing the config file";
27
28
    /**
29
     * Execute the console command.
30
     *
31
     * @return void
32
     * @throws ConfigException
33
     */
34 3
    public function handle()
35
    {
36 3
        $this->line('Refreshing the message cache...');
37
38 3
        $locales = Config::get('js-localization.locales');
39
40 3
        if(!is_array($locales)) {
41
          throw new ConfigException('Please set the "locales" config! See https://github.com/andywer/laravel-js-localization#configuration');
42
        }
43
44 3
        MessageCachingService::refreshCache();
45 3
        ConfigCachingService::refreshCache();
46 3
    }
47
    
48
    /**
49
     * Execute the console command.
50
     * Compatibility with previous Laravel 5.x versions.
51
     *
52
     * @return void
53
     * @throws ConfigException
54
     */
55
    public function fire()
56
    {
57
        $this->handle();
58
    }
59
}
60