StaffPersona   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 19 2
1
<?php
2
3
namespace App\Tenant\Loader\Identity;
4
5
use App\Entity\Staff as StaffEntity;
6
use Ds\Component\Database\Util\Objects;
0 ignored issues
show
Bug introduced by
The type Ds\Component\Database\Util\Objects 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\Tenant\Entity\Tenant;
0 ignored issues
show
Bug introduced by
The type Ds\Component\Tenant\Entity\Tenant 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
9
/**
10
 * Trait StaffPersona
11
 */
12
trait StaffPersona
13
{
14
    /**
15
     * @var \App\Service\StaffPersonaService
16
     */
17
    private $staffPersonaService;
18
19
    /**
20
     * @var string
21
     */
22
    private $path;
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function load(Tenant $tenant)
28
    {
29
        $data = (array) json_decode(json_encode($tenant->getData()));
30
        $objects = Objects::parseFile($this->path, $data);
31
        $manager = $this->staffPersonaService->getManager();
32
33
        foreach ($objects as $object) {
34
            $staff = $manager->getRepository(StaffEntity::class)->findOneBy(['uuid' => $object->staff]);
35
            $persona = $this->staffPersonaService->createInstance();
36
            $persona
37
                ->setStaff($staff)
38
                ->setUuid($object->uuid)
39
                ->setOwner($object->owner)
40
                ->setOwnerUuid($object->owner_uuid)
41
                ->setTitle((array) $object->title)
42
                ->setData((array) $object->data)
43
                ->setTenant($object->tenant);
44
            $manager->persist($persona);
45
            $manager->flush();
46
        }
47
    }
48
}
49