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

GetTestCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 10
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
    protected function configure()
22
    {
23
        parent::configure();
24
        $this->setName('test:api:get')
25
            ->setDescription('Api Test for get action.')
26
            ->setHelp('This command creates the Codeception Api Test for Get Action for given entity.');
27
    }
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
    protected function execute(InputInterface $input, OutputInterface $output)
38
    {
39
        $baseProvider = new BaseProvider($this->entityClassName);
40
41
        $generator = new GetGenerator(
42
            new CachedProvider(
43
                new DecoratedProvider(
44
                    $baseProvider,
45
                    new EntityDataDecorator(
46
                        $this->entityClassName,
47
                        new ReflectionEntitySpecProvider($this->entityClassName)
48
                    ),
49
                    new EntityIdDecorator($this->entityClassName),
50
                    new RelationsProviderDecorator($this->entityClassName),
51
                    new OwnerDecorator($this->entityClassName)
52
                )
53
            )
54
        );
55
        $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
        parent::execute($input, $output);
58
    }
59
}
60