Passed
Push — master ( 4e2390...be5d87 )
by Anthony
01:55
created

GuidAwareListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prePersist() 0 4 2
A __construct() 0 3 1
1
<?php
2
3
namespace Ribs\RibsAdminBundle\EventListener;
4
5
use Doctrine\ORM\Event\LifecycleEventArgs;
1 ignored issue
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...
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
use Ramsey\Uuid\Uuid;
1 ignored issue
show
Bug introduced by
The type Ramsey\Uuid\Uuid 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
class GuidAwareListener
10
{
11
	/**
12
	 * @var ContainerInterface
13
	 */
14
	private $container;
15
	
16
	public function __construct(ContainerInterface $container)
17
	{
18
		$this->container = $container;
19
	}
20
	
21
	public function prePersist($entity, LifecycleEventArgs $events)
0 ignored issues
show
Unused Code introduced by
The parameter $events is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
	public function prePersist($entity, /** @scrutinizer ignore-unused */ LifecycleEventArgs $events)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
	{
23
		if ($entity->getGuid() === null) {
24
			$entity->setGuid((string)Uuid::uuid4());
25
		}
26
	}
27
}
28