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

GuidAwareListener::prePersist()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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