Passed
Push — master ( 706b38...4fe946 )
by Jonathan
01:00
created

GenerateCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 57
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A handle() 0 11 1
1
<?php namespace Spekkionu\Assetcachebuster\Console;
2
3
4
use Illuminate\Console\Command;
5
use Illuminate\Contracts\Config\Repository as Config;
6
use Spekkionu\Assetcachebuster\HashReplacer\HashReplacerInterface;
7
8
/**
9
 * Generates a new asset cache hash
10
 */
11
class GenerateCommand extends Command
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'assetcachebuster:generate';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Generates a new asset hash';
26
    /**
27
     * @var HashReplacerInterface
28
     */
29
    private $hashReplacer;
30
    /**
31
     * @var Config
32
     */
33
    private $config;
34
35
36
    /**
37
     * Create a new key generator command.
38
     *
39
     * @param HashReplacerInterface $hashReplacer
40
     * @param Config $config
41
     */
42
    public function __construct(HashReplacerInterface $hashReplacer, Config $config)
43
    {
44
        parent::__construct();
45
46
        $this->hashReplacer = $hashReplacer;
47
        $this->config = $config;
48
    }
49
50
    /**
51
     * Execute the console command.
52
     *
53
     * @return void
54
     */
55
    public function handle()
56
    {
57
        $this->line('Generating new asset hash. Environment: <comment>' . $this->laravel->make('env') . '</comment>');
58
59
        $hash = $this->hashReplacer->replaceHash();
60
61
        $this->config->set('assetcachebuster.hash', $hash);
62
63
        $msg = "New hash {$hash} generated.";
64
        $this->info($msg);
65
    }
66
67
}
68