GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0b4676...ecfcbd )
by joseph
17s queued 14s
created

DtoCreator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 69
ccs 0
cts 42
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A configurePipeline() 0 6 1
A registerReplaceEntitiesNamespaceProcess() 0 6 1
A getEntityFqn() 0 3 1
A registerDataTransferObjectProcess() 0 5 1
A setNewObjectFqnFromEntityFqn() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\DataTransferObjects;
4
5
// phpcs:disable
6
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\CodeHelper;
7
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\AbstractCreator;
8
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Process\ReplaceEntitiesSubNamespaceProcess;
9
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Process\Src\Entity\DataTransferObjects\CreateDtoBodyProcess;
10
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FileFactory;
11
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FindReplaceFactory;
12
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File;
13
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\NamespaceHelper;
14
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\ReflectionHelper;
15
use EdmondsCommerce\DoctrineStaticMeta\Config;
16
17
// phpcs:enable
18
class DtoCreator extends AbstractCreator
19
{
20
    public const FIND_NAME = 'TemplateEntityDto';
21
22
    public const TEMPLATE_PATH = self::ROOT_TEMPLATE_PATH .
23
                                 '/src/Entity/DataTransferObjects/' .
24
                                 self::FIND_NAME .
25
                                 '.php';
26
    /**
27
     * @var ReflectionHelper
28
     */
29
    private $reflectionHelper;
30
    /**
31
     * @var string
32
     */
33
    private $entityFqn;
34
    /**
35
     * @var CodeHelper
36
     */
37
    private $codeHelper;
38
39
    public function __construct(
40
        FileFactory $fileFactory,
41
        NamespaceHelper $namespaceHelper,
42
        File\Writer $fileWriter,
43
        Config $config,
44
        FindReplaceFactory $findReplaceFactory,
45
        ReflectionHelper $reflectionHelper,
46
        CodeHelper $codeHelper
47
    ) {
48
        parent::__construct($fileFactory, $namespaceHelper, $fileWriter, $config, $findReplaceFactory);
49
        $this->reflectionHelper = $reflectionHelper;
50
        $this->codeHelper       = $codeHelper;
51
    }
52
53
    public function configurePipeline(): void
54
    {
55
        parent::configurePipeline();
56
        $this->registerReplaceEntitiesNamespaceProcess();
57
        $this->registerDataTransferObjectProcess();
58
        $this->registerEntityReplaceName($this->getEntityFqn());
59
    }
60
61
    protected function registerReplaceEntitiesNamespaceProcess(): void
62
    {
63
        $process = new ReplaceEntitiesSubNamespaceProcess();
64
        $process->setEntityFqn($this->getEntityFqn());
65
        $process->setProjectRootNamespace($this->projectRootNamespace);
0 ignored issues
show
Bug introduced by
It seems like $this->projectRootNamespace can also be of type null; however, parameter $projectRootNamespace of EdmondsCommerce\Doctrine...tProjectRootNamespace() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

65
        $process->setProjectRootNamespace(/** @scrutinizer ignore-type */ $this->projectRootNamespace);
Loading history...
66
        $this->pipeline->register($process);
67
    }
68
69
    private function getEntityFqn(): string
70
    {
71
        return $this->entityFqn ?? $this->namespaceHelper->getEntityFqnFromEntityDtoFqn($this->newObjectFqn);
0 ignored issues
show
Deprecated Code introduced by
The function EdmondsCommerce\Doctrine...tyFqnFromEntityDtoFqn() has been deprecated: please use the static method on the DTO directly ( Ignorable by Annotation )

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

71
        return $this->entityFqn ?? /** @scrutinizer ignore-deprecated */ $this->namespaceHelper->getEntityFqnFromEntityDtoFqn($this->newObjectFqn);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Bug introduced by
It seems like $this->newObjectFqn can also be of type null; however, parameter $entityDtoFqn of EdmondsCommerce\Doctrine...tyFqnFromEntityDtoFqn() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

71
        return $this->entityFqn ?? $this->namespaceHelper->getEntityFqnFromEntityDtoFqn(/** @scrutinizer ignore-type */ $this->newObjectFqn);
Loading history...
72
    }
73
74
    private function registerDataTransferObjectProcess(): void
75
    {
76
        $process = new CreateDtoBodyProcess($this->reflectionHelper, $this->codeHelper, $this->namespaceHelper);
77
        $process->setEntityFqn($this->getEntityFqn());
78
        $this->pipeline->register($process);
79
    }
80
81
    public function setNewObjectFqnFromEntityFqn(string $entityFqn): self
82
    {
83
        $this->entityFqn    = $entityFqn;
84
        $this->newObjectFqn = $this->namespaceHelper->getEntityDtoFqnFromEntityFqn($entityFqn);
85
86
        return $this;
87
    }
88
}
89