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
Pull Request — master (#153)
by joseph
07:15
created

createTargetFileObject()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 9
nc 5
nop 1
dl 0
loc 16
rs 9.6111
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\Embeddable;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\AbstractCreator;
6
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Process\ReplaceNameProcess;
7
8
abstract class AbstractEmbeddableCreator extends AbstractCreator
9
{
10
    /**
11
     * @var string|null
12
     */
13
    protected $catName;
14
15
    /**
16
     * @var string|null
17
     */
18
    protected $name;
19
20
21
    public function createTargetFileObject(string $newObjectFqn = null): AbstractCreator
22
    {
23
        if (null !== $newObjectFqn) {
24
            throw new \InvalidArgumentException('You do not pass a new object FQN into this creator');
25
        }
26
        if ('' === (string)$this->catName) {
27
            throw new \RuntimeException('You must call setCatName before running this creator');
28
        }
29
        if ('' === (string)$this->name) {
30
            throw new \RuntimeException('You must call setName before running this creator');
31
        }
32
        if ('' === (string)$this->projectRootNamespace) {
33
            throw new \RuntimeException('You must call setProjectRootNamespace before running this creator');
34
        }
35
36
        return parent::createTargetFileObject($this->getNewObjectFqn());
37
    }
38
39
    abstract protected function getNewObjectFqn(): string;
40
41
    /**
42
     * @param string $catName
43
     *
44
     * @return AbstractEmbeddableCreator
45
     */
46
    public function setCatName(string $catName): AbstractEmbeddableCreator
47
    {
48
        $this->catName = $catName;
49
50
        return $this;
51
    }
52
53
    /**
54
     * @param string $name
55
     *
56
     * @return AbstractEmbeddableCreator
57
     */
58
    public function setName(string $name): AbstractEmbeddableCreator
59
    {
60
        $this->name = $name;
61
62
        return $this;
63
    }
64
65
    protected function configurePipeline(): void
66
    {
67
        parent::configurePipeline();
68
        $this->registerReplaceSkeletonEmbeddable();
69
70
    }
71
72
    private function registerReplaceSkeletonEmbeddable(): void
73
    {
74
        $replaceName = new ReplaceNameProcess();
75
        $replaceName->setArgs(
76
            'CatName',
77
            $this->catName
0 ignored issues
show
Bug introduced by
It seems like $this->catName can also be of type null; however, parameter $newObjectBaseName of EdmondsCommerce\Doctrine...eNameProcess::setArgs() 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

77
            /** @scrutinizer ignore-type */ $this->catName
Loading history...
78
        );
79
        $this->pipeline->register($replaceName);
80
        $replaceName = new ReplaceNameProcess();
81
        $replaceName->setArgs(
82
            'Skeleton',
83
            $this->name
84
        );
85
        $this->pipeline->register($replaceName);
86
    }
87
88
89
}