Service   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 22 2
1
<?php
2
3
namespace App\Fixture;
4
5
use App\Entity\Service as ServiceEntity;
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
9
/**
10
 * Trait Service
11
 */
12
trait Service
13
{
14
    use Yaml;
15
16
    /**
17
     * @var string
18
     */
19
    private $path;
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load(ObjectManager $manager)
25
    {
26
        $objects = $this->parse($this->path);
27
28
        foreach ($objects as $object) {
29
            $service = new ServiceEntity;
30
            $service
31
                ->setUuid($object->uuid)
32
                ->setOwner($object->owner)
33
                ->setOwnerUuid($object->owner_uuid)
34
                ->setSlug($object->slug)
35
                ->setTitle((array) $object->title)
36
                ->setDescription((array) $object->description)
37
                ->setPresentation((array) $object->presentation)
38
                ->setData(json_decode(json_encode($object->data), true))
39
                ->setEnabled($object->enabled)
40
                ->setWeight($object->weight)
41
                ->setTenant($object->tenant);
42
            $manager->persist($service);
43
        }
44
45
        $manager->flush();
46
    }
47
}
48