CacheCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
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();
0 ignored issues
show
Bug introduced by
The method getCachedRoutesPath() does not exist on Nip\Container\Container. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        /** @scrutinizer ignore-call */ 
31
        $configPath = $app->getCachedRoutesPath();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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
The assignment to $matcher is dead and can be removed.
Loading history...
36
37
        $this->info('Routes  cached successfully!');
38
39
        return 0;
40
    }
41
}
42