Passed
Push — master ( b66278...af918b )
by Mauro
01:50
created

CreateSchemaCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the InMemoryList package.
4
 *
5
 * (c) Mauro Cassani<https://github.com/mauretto78>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 */
10
11
namespace InMemoryList\Command;
12
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16 View Code Duplication
class CreateSchemaCommand extends BaseCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * CreateSchemaCommand constructor.
20
     *
21
     * @param array $parameters
22
     */
23
    public function __construct(array $parameters)
24
    {
25
        parent::__construct(
26
            'iml_cache_create_schema',
27
            'pdo',
28
            $parameters
29
        );
30
    }
31
32
    protected function configure()
33
    {
34
        $this
35
            ->setName('iml:cache:schema:create')
36
            ->setDescription('Create database schema.')
37
            ->setHelp('This command creates the database schema (only with PDO driver).')
38
        ;
39
    }
40
41
    protected function execute(InputInterface $input, OutputInterface $output)
42
    {
43
        $cache = $this->createClient($this->driver, $this->parameters);
44
45
        try {
46
            $cache->getRepository()->createSchema();
0 ignored issues
show
Bug introduced by
The method createSchema() does not exist on InMemoryList\Domain\Mode...ListRepositoryInterface. Did you maybe mean create()? ( Ignorable by Annotation )

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

46
            $cache->getRepository()->/** @scrutinizer ignore-call */ createSchema();

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...
47
48
            $output->writeln('<fg=red>['.$this->driver.'] Schema was successful created.</>');
49
        } catch (\Exception $e) {
50
            $output->writeln('<fg=red>['.$this->driver.'] Error in schema creation: '.$e->getMessage().' .</>');
51
        }
52
    }
53
}
54