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 (#58)
by joseph
18:31
created

EntityEmbeddableSetter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 28
rs 10
c 0
b 0
f 0
ccs 17
cts 17
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setEntityHasEmbeddable() 0 16 1
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator\Embeddable;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\CodeHelper;
6
use gossi\codegen\model\PhpClass;
7
use gossi\codegen\model\PhpInterface;
8
use gossi\codegen\model\PhpTrait;
9
10
/**
11
 * Class EntityEmbeddableSetter
12
 *
13
 * @package EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator\Embeddable
14
 * @SuppressWarnings(PHPMD.StaticAccess)
15
 */
16
class EntityEmbeddableSetter
17
{
18
    /**
19
     * @var CodeHelper
20
     */
21
    protected $codeHelper;
22
23 9
    public function __construct(CodeHelper $codeHelper)
24
    {
25 9
        $this->codeHelper = $codeHelper;
26 9
    }
27
28 8
    public function setEntityHasEmbeddable(string $entityFqn, string $embeddableTraitFqn)
29
    {
30 8
        $entityReflection     = new \ReflectionClass($entityFqn);
31 8
        $entity               = PhpClass::fromFile($entityReflection->getFileName());
32 8
        $embeddableReflection = new \ReflectionClass($embeddableTraitFqn);
33 8
        $trait                = PhpTrait::fromFile($embeddableReflection->getFileName());
34 8
        $interfaceFqn         = \str_replace(
35 8
            'Trait',
36 8
            'Interface',
37 8
            $embeddableTraitFqn
38
        );
39 8
        $interfaceReflection  = new \ReflectionClass($interfaceFqn);
40 8
        $interface            = PhpInterface::fromFile($interfaceReflection->getFileName());
41 8
        $entity->addTrait($trait)
42 8
               ->addInterface($interface);
43 8
        $this->codeHelper->generate($entity, $entityReflection->getFileName());
44 8
    }
45
}
46