TermStoreFactory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 7
dl 0
loc 40
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A newTermStoreInstaller() 0 6 1
A newEntityIdLookup() 0 6 1
A newTermStoreWriter() 0 3 1
A newLabelLookup() 0 3 1
A newTermStore() 0 3 1
1
<?php
2
3
namespace Queryr\TermStore;
4
5
use Doctrine\DBAL\Connection;
6
7
/**
8
 * Package public
9
 * @since 0.2
10
 *
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 */
14
class TermStoreFactory {
15
16
	private $connection;
17
	private $config;
18
19
	public function __construct( Connection $connection, TermStoreConfig $config ) {
20
		$this->connection = $connection;
21
		$this->config = $config;
22
	}
23
24
	public function newTermStoreInstaller(): TermStoreInstaller {
25
		return new TermStoreInstaller(
26
			$this->connection->getSchemaManager(),
27
			$this->config
28
		);
29
	}
30
31
	public function newEntityIdLookup(): EntityIdLookup {
32
		$labelTable = new TableQueryExecutor( $this->connection, $this->config->getLabelTableName() );
33
		$aliasesTable = new TableQueryExecutor( $this->connection, $this->config->getAliasesTableName() );
34
35
		return new IdLookup( $labelTable, $aliasesTable );
36
	}
37
38
	public function newTermStoreWriter(): TermStoreWriter {
39
		return new TermStoreWriter( $this->connection, $this->config );
40
	}
41
42
	public function newLabelLookup(): LabelLookup {
43
		return $this->newTermStore();
44
	}
45
46
	/**
47
	 * Work with a more segregated interface (TermStoreWriter, EntityIdLookup, LabelLookup) if you can.
48
	 */
49
	public function newTermStore(): TermStore {
50
		return new TermStore( $this->connection, $this->config );
51
	}
52
53
}