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

VirtualTables::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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