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.
Passed
Pull Request — master (#154)
by joseph
25:46
created

AddAssociationEntitiesModifier   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 39
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestEntityGeneratorForEntity() 0 10 2
A addAssociationEntities() 0 3 1
A modifyEntities() 0 4 2
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\Fixtures\Modifiers;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityGenerator\TestEntityGenerator;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityGenerator\TestEntityGeneratorFactory;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\Fixtures\FixtureEntitiesModifierInterface;
9
10
/**
11
 * Use this modifier along when creating your Fixture instance to generate fixtures with all associations set
12
 */
13
class AddAssociationEntitiesModifier implements FixtureEntitiesModifierInterface
14
{
15
    /**
16
     * @var TestEntityGeneratorFactory
17
     */
18
    private $testEntityGeneratorFactory;
19
20
    /**
21
     * @var TestEntityGenerator
22
     */
23
    private $testEntityGenerator;
24
25
    public function __construct(TestEntityGeneratorFactory $testEntityGeneratorFactory)
26
    {
27
        $this->testEntityGeneratorFactory = $testEntityGeneratorFactory;
28
    }
29
30
    public function modifyEntities(array &$entities): void
31
    {
32
        foreach ($entities as $entity) {
33
            $this->addAssociationEntities($entity);
34
        }
35
    }
36
37
    private function addAssociationEntities(EntityInterface $entity): void
38
    {
39
        $this->getTestEntityGeneratorForEntity($entity)->addAssociationEntities($entity);
40
    }
41
42
    private function getTestEntityGeneratorForEntity(EntityInterface $entity): TestEntityGenerator
43
    {
44
        if ($this->testEntityGenerator instanceof TestEntityGenerator) {
0 ignored issues
show
introduced by
$this->testEntityGenerator is always a sub-type of EdmondsCommerce\Doctrine...tor\TestEntityGenerator.
Loading history...
45
            return $this->testEntityGenerator;
46
        }
47
        $this->testEntityGenerator = $this->testEntityGeneratorFactory->createForEntityFqn(
48
            $entity::getEntityFqn()
49
        );
50
51
        return $this->testEntityGenerator;
52
    }
53
}
54