Staff   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 15 2
1
<?php
2
3
namespace App\Tenant\Loader\Identity;
4
5
use App\Entity\Role;
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
use LogicException;
9
10
/**
11
 * Trait Staff
12
 */
13
trait Staff
14
{
15
    /**
16
     * @var \App\Service\StaffService
17
     */
18
    private $staffService;
19
20
    /**
21
     * @var string
22
     */
23
    private $path;
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function load(Tenant $tenant)
29
    {
30
        $data = (array) json_decode(json_encode($tenant->getData()));
31
        $objects = Objects::parseFile($this->path, $data);
32
        $manager = $this->staffService->getManager();
33
34
        foreach ($objects as $object) {
35
            $staff = $this->staffService->createInstance();
36
            $staff
37
                ->setUuid($object->uuid)
38
                ->setOwner($object->owner)
39
                ->setOwnerUuid($object->owner_uuid)
40
                ->setTenant($object->tenant);
41
            $manager->persist($staff);
42
            $manager->flush();
43
        }
44
    }
45
}
46