EntityFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 15
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createEntity() 0 8 2
1
<?php
2
namespace SpareParts\Pillar\Entity;
3
4
use SpareParts\Pillar\Assistant\Dibi\IEntityFactory;
5
use SpareParts\Pillar\Mapper\IMapper;
6
7
class EntityFactory implements IEntityFactory
8
{
9
	/**
10
	 * @param string $entityClassName
11
	 * @param mixed[] $data
12
	 * @return IEntity
13
	 */
14
	public function createEntity($entityClassName, array $data)
15
	{
16
		// Try to fix strange Dibi datetime behaviour by using standard (and immutable!) datetime class
17 1
		$data = array_map(function($column) {
18 1
			return ($column instanceof \DateTime) ? \DateTimeImmutable::createFromMutable($column) : $column;
19 1
		}, $data);
20
21 1
		return new $entityClassName($data);
22
	}
23
}
24