EntityManagerAnnotation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 15
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 2
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL or Commercial license.
5
 *
6
 * @package maslosoft/mangan
7
 * @licence AGPL or Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]>
9
 * @copyright Copyright (c) Maslosoft
10
 * @copyright Copyright (c) Others as mentioned in code
11
 * @link https://maslosoft.com/mangan/
12
 */
13
14
namespace Maslosoft\Mangan\Annotations;
15
16
use Maslosoft\Addendum\Utilities\ClassChecker;
17
use Maslosoft\Mangan\Meta\ManganTypeAnnotation;
18
use UnexpectedValueException;
19
20
/**
21
 * Set custom entity manager class
22
 * @Target('class')
23
 * @template EntityManager(${entityManagerLiteral})
24
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
25
 */
26
class EntityManagerAnnotation extends ManganTypeAnnotation
27
{
28
29
	public $value = null;
30
31
	public function init()
32
	{
33
		if (!ClassChecker::exists($this->value))
34
		{
35
			throw new UnexpectedValueException(sprintf('Class `%s` not found on @EntityManager annotation, on model `%s`', $this->value, $this->name));
36
		}
37
		$this->getEntity()->entityManager = $this->value;
38
	}
39
40
}
41