IndividualPersona   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 24 3
1
<?php
2
3
namespace App\Fixture;
4
5
use App\Entity\IndividualPersona as IndividualPersonaEntity;
6
use Doctrine\Common\Persistence\ObjectManager;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Persistence\ObjectManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Ds\Component\Database\Fixture\Yaml;
0 ignored issues
show
Bug introduced by
The type Ds\Component\Database\Fixture\Yaml was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use LogicException;
9
10
/**
11
 * Trait IndividualPersona
12
 */
13
trait IndividualPersona
14
{
15
    use Yaml;
16
17
    /**
18
     * @var string
19
     */
20
    private $path;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function load(ObjectManager $manager)
26
    {
27
        $objects = $this->parse($this->path);
28
29
        foreach ($objects as $object) {
30
            $individual = $this->getReference($object->individual);
31
32
            if (!$individual) {
33
                throw new LogicException('Individual "'.$object->individual.'" does not exist.');
34
            }
35
36
            $persona = new IndividualPersonaEntity;
37
            $persona
38
                ->setIndividual($individual)
39
                ->setUuid($object->uuid)
40
                ->setOwner($object->owner)
41
                ->setOwnerUuid($object->owner_uuid)
42
                ->setTitle((array) $object->title)
43
                ->setData((array) $object->data)
44
                ->setTenant($object->tenant);
45
            $manager->persist($persona);
46
        }
47
48
        $manager->flush();
49
    }
50
}
51