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 ( 75bdf9...8faa57 )
by joseph
83:56 queued 81:04
created

ReplaceEntityIdFieldProcess::getUseStatement()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 16
nc 5
nop 0
dl 0
loc 20
ccs 0
cts 12
cp 0
crap 30
rs 9.4222
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Process;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\IdFieldTrait;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\IntegerIdFieldTrait;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\UuidFieldTrait;
10
11
class ReplaceEntityIdFieldProcess implements ProcessInterface
12
{
13
14
    public const FIND_USE_STATEMENT = 'use DSM\Fields\Traits\PrimaryKey\IdFieldTrait;';
15
    /**
16
     * @var string
17
     */
18
    private $idTraitFqn;
19
20
    /**
21
     * Specify the IdFieldTrait fully qualified name, eg UuidFieldTrait::class
22
     *
23
     * @param string $idTraitFqn
24
     *
25
     * @return ReplaceEntityIdFieldProcess
26
     */
27
    public function setIdTraitFqn(string $idTraitFqn): self
28
    {
29
        $this->idTraitFqn = $idTraitFqn;
30
31
        return $this;
32
    }
33
34
    public function run(File\FindReplace $findReplace): void
35
    {
36
        if (null === $this->idTraitFqn) {
37
            throw new \RuntimeException('you must set the IdTraitFqn');
38
        }
39
        $findReplace->findReplace(self::FIND_USE_STATEMENT, $this->getUseStatement());
40
    }
41
42
    /**
43
     * Get the use statement to replace it with
44
     *
45
     * @return string
46
     */
47
    private function getUseStatement(): string
48
    {
49
        switch ($this->idTraitFqn) {
50
            case IdFieldTrait::class:
51
                $useStatement = 'use DSM\Fields\Traits\PrimaryKey\IdFieldTrait;';
52
                break;
53
            case IntegerIdFieldTrait::class:
54
                $useStatement = 'use DSM\Fields\Traits\PrimaryKey\IntegerIdFieldTrait;';
55
                break;
56
            case NonBinaryUuidFieldTrait::class:
57
                $useStatement = 'use DSM\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait;';
58
                break;
59
            case UuidFieldTrait::class:
60
                $useStatement = 'use DSM\Fields\Traits\PrimaryKey\UuidFieldTrait;';
61
                break;
62
            default:
63
                throw new \LogicException('Unknown trait selected ' . $this->idTraitFqn);
64
        }
65
66
        return $useStatement;
67
    }
68
}
69