TestEnvironment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A newInstance() 0 3 1
A __construct() 0 16 2
A getFactory() 0 3 1
1
<?php
2
3
namespace Tests\Queryr\Replicator\Integration;
4
5
use Doctrine\DBAL\DriverManager;
6
use Queryr\Replicator\ServiceFactory;
7
8
/**
9
 * @licence GNU GPL v2+
10
 * @author Jeroen De Dauw < [email protected] >
11
 */
12
class TestEnvironment {
13
14
	public static function newInstance() {
15
		return new self();
16
	}
17
18
	/**
19
	 * @var ServiceFactory
20
	 */
21
	private $factory;
22
23
	private function __construct() {
24
		$connection = DriverManager::getConnection( array(
25
			'driver' => 'pdo_sqlite',
26
			'memory' => true,
27
		) );
28
29
		$this->factory = ServiceFactory::newFromConnection( $connection );
30
31
		$this->factory->newEntityStoreInstaller()->install();
32
33
		if ( defined( 'WIKIBASE_QUERYENGINE_VERSION' ) ) {
34
			$this->factory->newQueryEngineInstaller()->install();
35
		}
36
37
		$this->factory->newTermStoreInstaller()->install();
38
	}
39
40
	/**
41
	 * @return ServiceFactory
42
	 */
43
	public function getFactory(): ServiceFactory {
44
		return $this->factory;
45
	}
46
47
}
48