Completed
Push — master ( 807973...39044b )
by Oleg
04:12
created

GetsTestCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 2
dl 0
loc 26
ccs 0
cts 18
cp 0
crap 2
rs 9.7
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Command\Tests\Api;
5
6
use SlayerBirden\DFCodeGeneration\Command\AbstractApiCommand;
7
use SlayerBirden\DFCodeGeneration\Generator\Config\Providers\Decorators\EntityIdDecorator;
8
use SlayerBirden\DFCodeGeneration\Generator\Config\Providers\Decorators\OwnerDecorator;
9
use SlayerBirden\DFCodeGeneration\Generator\Controllers\Providers\Decorators\EntityNamePluralDecorator;
10
use SlayerBirden\DFCodeGeneration\Generator\Controllers\Providers\Decorators\RelationsProviderDecorator;
11
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\BaseProvider;
12
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\CachedProvider;
13
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\DecoratedProvider;
14
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\GetsGenerator;
15
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\Providers\Decorators\EntityDataDecorator;
16
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\Providers\Decorators\PluralDecorator;
17
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\ReflectionEntitySpecProvider;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
final class GetsTestCommand extends AbstractApiCommand
22
{
23
    protected function configure()
24
    {
25
        parent::configure();
26
        $this->setName('test:api:gets')
27
            ->setDescription('Api Test for get multiple action.')
28
            ->setHelp('This command creates the Codeception Api Test for Get Multiple Action for given entity.');
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     * @param InputInterface $input
34
     * @param OutputInterface $output
35
     * @throws \Twig_Error_Loader
36
     * @throws \Twig_Error_Runtime
37
     * @throws \Twig_Error_Syntax
38
     */
39
    protected function execute(InputInterface $input, OutputInterface $output)
40
    {
41
        $baseProvider = new BaseProvider($this->entityClassName);
42
43
        $generator = new GetsGenerator(
44
            new CachedProvider(
45
                new DecoratedProvider(
46
                    $baseProvider,
47
                    new EntityDataDecorator(
48
                        $this->entityClassName,
49
                        new ReflectionEntitySpecProvider($this->entityClassName)
50
                    ),
51
                    new PluralDecorator(
52
                        $this->entityClassName,
53
                        new ReflectionEntitySpecProvider($this->entityClassName)
54
                    ),
55
                    new EntityIdDecorator($this->entityClassName),
56
                    new RelationsProviderDecorator($this->entityClassName),
57
                    new OwnerDecorator($this->entityClassName),
58
                    new EntityNamePluralDecorator()
59
                )
60
            )
61
        );
62
        $this->writer->write($generator->generate(), $generator->getFileName());
0 ignored issues
show
Bug introduced by
The method write() does not exist on null. ( Ignorable by Annotation )

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

62
        $this->writer->/** @scrutinizer ignore-call */ 
63
                       write($generator->generate(), $generator->getFileName());

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...
63
64
        parent::execute($input, $output);
65
    }
66
}
67