Completed
Push — master ( 39044b...ce5fed )
by Oleg
02:16
created

GetTestCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 2
dl 0
loc 21
ccs 14
cts 14
cp 1
crap 1
rs 9.8333
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\RelationsProviderDecorator;
10
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\BaseProvider;
11
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\CachedProvider;
12
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\DecoratedProvider;
13
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\GetGenerator;
14
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\Providers\Decorators\EntityDataDecorator;
15
use SlayerBirden\DFCodeGeneration\Generator\Tests\Api\ReflectionEntitySpecProvider;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
final class GetTestCommand extends AbstractApiCommand
20
{
21 2
    protected function configure()
22
    {
23 2
        parent::configure();
24 2
        $this->setName('test:api:get')
25 2
            ->setDescription('Api Test for get action.')
26 2
            ->setHelp('This command creates the Codeception Api Test for Get Action for given entity.');
27 2
    }
28
29
    /**
30
     * {@inheritdoc}
31
     * @param InputInterface $input
32
     * @param OutputInterface $output
33
     * @throws \Twig_Error_Loader
34
     * @throws \Twig_Error_Runtime
35
     * @throws \Twig_Error_Syntax
36
     */
37 2
    protected function execute(InputInterface $input, OutputInterface $output)
38
    {
39 2
        $baseProvider = new BaseProvider($this->entityClassName);
40
41 2
        $generator = new GetGenerator(
42 2
            new CachedProvider(
43 2
                new DecoratedProvider(
44 2
                    $baseProvider,
45 2
                    new EntityDataDecorator(
46 2
                        $this->entityClassName,
47 2
                        new ReflectionEntitySpecProvider($this->entityClassName)
48
                    ),
49 2
                    new EntityIdDecorator($this->entityClassName),
50 2
                    new RelationsProviderDecorator($this->entityClassName),
51 2
                    new OwnerDecorator($this->entityClassName)
52
                )
53
            )
54
        );
55 2
        $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

55
        $this->writer->/** @scrutinizer ignore-call */ 
56
                       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...
56
57 2
        parent::execute($input, $output);
58 2
    }
59
}
60