AnonymousPersonaUnloader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Tenant\Unloader;
4
5
use App\Entity\AnonymousPersona;
6
use Doctrine\ORM\EntityManagerInterface;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityManagerInterface 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 Ds\Component\Tenant\Loader\Unloader;
0 ignored issues
show
Bug introduced by
The type Ds\Component\Tenant\Loader\Unloader 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...
9
10
/**
11
 * Class AnonymousPersonaUnloader
12
 */
13
final class AnonymousPersonaUnloader implements Unloader
14
{
15
    /**
16
     * @var \Doctrine\ORM\EntityManagerInterface
17
     */
18
    private $entityManager;
19
20
    /**
21
     * Constructor
22
     *
23
     * @param \Doctrine\ORM\EntityManagerInterface $entityManager
24
     */
25
    public function __construct(EntityManagerInterface $entityManager)
26
    {
27
        $this->entityManager = $entityManager;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function unload(Tenant $tenant)
34
    {
35
        $builder = $this->entityManager->getRepository(AnonymousPersona::class)->createQueryBuilder('e');
36
        $builder
37
            ->delete()
38
            ->where('e.tenant = :tenant')
39
            ->setParameter('tenant', $tenant->getUuid());
40
        $query = $builder->getQuery();
41
        $query->execute();
42
    }
43
}
44