Passed
Push — develop ( d38868...21087d )
by Mario
01:26
created

UserListener::postPersist()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\EventListener\Entity\Registration;
4
5
use App\Entity\Registration;
6
use App\Service\RegistrationService;
7
use Doctrine\ORM\Event\LifecycleEventArgs;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Event\LifecycleEventArgs 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\Container\Attribute\Container;
0 ignored issues
show
Bug introduced by
The type Ds\Component\Container\Attribute\Container 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
use Ds\Component\Model\Attribute\Enabled;
0 ignored issues
show
Bug introduced by
The type Ds\Component\Model\Attribute\Enabled 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...
10
use Ds\Component\Model\Type\Enableable;
0 ignored issues
show
Bug introduced by
The type Ds\Component\Model\Type\Enableable 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...
11
use Symfony\Component\DependencyInjection\ContainerInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...tion\ContainerInterface 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...
12
13
/**
14
 * Class UserListener
15
 */
16
final class UserListener implements Enableable
17
{
18
    use Container;
19
    use Enabled;
20
21
    /**
22
     * Constructor
23
     *
24
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
25
     */
26
    public function __construct(ContainerInterface $container)
27
    {
28
        $this->container = $container;
0 ignored issues
show
Bug Best Practice introduced by
The property container does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
        $this->enabled = true;
0 ignored issues
show
Bug Best Practice introduced by
The property enabled does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
    }
31
32
    /**
33
     * Create user on registration
34
     *
35
     * @param \Doctrine\ORM\Event\LifecycleEventArgs $event
36
     */
37
    public function postPersist(LifecycleEventArgs $event)
38
    {
39
        if (!$this->isEnabled()) {
40
            return;
41
        }
42
43
        $entity = $event->getEntity();
44
45
        if (!$entity instanceof Registration) {
46
            return;
47
        }
48
49
        $this->container->get(RegistrationService::class)->createUser($entity);
50
    }
51
}
52