Completed
Push — master ( c131ba...eae540 )
by Ron
03:34
created

VirtualTables   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A has() 0 3 1
A get() 0 6 2
1
<?php
2
namespace Kir\MySQL\Tools;
3
4
use Kir\MySQL\Builder\Select;
5
6
class VirtualTables {
7
	/** @var Select[] */
8
	private $virtualTables = [];
9
	
10
	/**
11
	 * @param string $tableName
12
	 * @param Select $select
13
	 * @return $this
14
	 */
15
	public function add($tableName, Select $select) {
16
		$this->virtualTables[$tableName] = $select;
17
		return $this;
18
	}
19
	
20
	/**
21
	 * @param string $tableName
22
	 * @return bool
23
	 */
24
	public function has($tableName) {
25
		return array_key_exists($tableName, $this->virtualTables);
26
	}
27
	
28
	/**
29
	 * @param string $tableName
30
	 * @return Select|null
31
	 */
32
	public function get($tableName) {
33
		if($this->has($tableName)) {
34
			return $this->virtualTables[$tableName];
35
		}
36
		return null;
37
	}
38
}
39