EntityMapping::getTables()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace SpareParts\Pillar\Mapper\Dibi;
3
4
class EntityMapping implements IEntityMapping
5
{
6
	/**
7
	 * @var TableInfo[]
8
	 */
9
	private $tableInfoList = [];
10
11
	/**
12
	 * @var ColumnInfo[]
13
	 */
14
	private $columnInfoList = [];
15
16
	/**
17
	 * @var string
18
	 */
19
	private $entityClassName;
20
21
	/**
22
	 * @var bool
23
	 */
24
	private $isVirtualEntity;
25
26
	/**
27
	 * @param string $entityClassName
28
	 * @param TableInfo[] $tableInfoList
29
	 * @param ColumnInfo[] $columnInfoList
30
	 * @param bool $isVirtualEntity
31
	 */
32 6
	public function __construct($entityClassName, array $tableInfoList, array $columnInfoList, $isVirtualEntity = false)
33
	{
34 6
		$this->tableInfoList = $tableInfoList;
35 6
		$this->columnInfoList = $columnInfoList;
36 6
		$this->entityClassName = $entityClassName;
37 6
		$this->isVirtualEntity = $isVirtualEntity;
38 6
	}
39
40
	/**
41
	 * @return string
42
	 */
43 2
	public function getEntityClassName()
44
	{
45 2
		return $this->entityClassName;
46
	}
47
48
	/**
49
	 * @return TableInfo[]
50
	 */
51 6
	public function getTables()
52
	{
53 6
		return $this->tableInfoList;
54
	}
55
56
	/**
57
	 * @param string $tableIdentifier
58
	 * @return ColumnInfo[]
59
	 */
60
	public function getColumnsForTable($tableIdentifier)
61
	{
62 5
		return array_filter($this->columnInfoList, function (ColumnInfo $columnInfo) use ($tableIdentifier) {
63 5
			return ($columnInfo->getTableInfo()->getIdentifier() === $tableIdentifier);
64 5
		});
65
	}
66
67
	/**
68
	 * @return bool
69
	 */
70 3
	public  function isVirtualEntity() {
71 3
		return $this->isVirtualEntity;
72
	}
73
}
74