Passed
Push — master ( b4cb9f...51bac7 )
by Anthony
02:22
created

GuidAwareListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prePersist() 0 4 2
A __construct() 0 3 1
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\EventListener;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
use Ramsey\Uuid\Uuid;
7
8
class GuidAwareListener
9
{
10
	/**
11
	 * @var ContainerInterface
12
	 */
13
	private $container;
14
	
15
	public function __construct(ContainerInterface $container)
16
	{
17
		$this->container = $container;
18
	}
19
	
20
	public function prePersist($entity)
21
	{
22
		if ($entity->getGuid() === null) {
23
			$entity->setGuid((string)Uuid::uuid4());
24
		}
25
	}
26
}
27