BusinessUnit   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

1 Method

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