Completed
Branch master (df0330)
by Gabriel
08:50 queued 06:43
created

CacheCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A handle() 0 16 1
1
<?php
2
3
namespace Nip\Router\Console;
4
5
use ByTIC\Console\Command;
6
use Exception;
7
8
/**
9
 * Class CacheCommand
10
 * @package Nip\Config\Console
11
 */
12
class CacheCommand extends Command
13
{
14
    protected function configure()
15
    {
16
        parent::configure();
17
        $this->setName('router:cache');
18
        $this->setDescription('Create a route cache file for faster route registration');
19
    }
20
21
    /**
22
     * @inheritDoc
23
     * @throws Exception
24
     */
25
    protected function handle()
26
    {
27
        $this->call('router:clear');
28
29
        $app = $this->getByticApp();
30
        $configPath = $app->getCachedRoutesPath();
31
32
        $router = $this->getFromContainer('router');
33
        $router->setOption('cache_dir', $configPath);
34
35
        $matcher = $router->getMatcher();
0 ignored issues
show
Unused Code introduced by
$matcher is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
36
37
        $this->info('Routes  cached successfully!');
38
39
        return 0;
40
    }
41
}
42