TestEnvironment   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
eloc 14
c 4
b 0
f 0
dl 0
loc 34
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A newInstance() 0 6 1
A getEntityManager() 0 2 1
A install() 0 9 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\AddressChangeContext\Tests;
6
7
use Doctrine\ORM\EntityManager;
8
9
/**
10
 * @license GPL-2.0-or-later
11
 */
12
class TestEnvironment {
13
14
	private TestAddressChangeContextFactory $factory;
15
16
	private function __construct() {
17
		$this->factory = new TestAddressChangeContextFactory(
18
			[
19
			'driver' => 'pdo_sqlite',
20
			'memory' => true,
21
			]
22
		);
23
	}
24
25
	public static function newInstance(): self {
26
		$environment = new self();
27
28
		$environment->install();
29
30
		return $environment;
31
	}
32
33
	private function install(): void {
34
		$schema = new SchemaCreator( $this->getEntityManager() );
35
36
		try {
37
			$schema->dropSchema();
38
		} catch ( \Exception $ex ) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
39
		}
40
41
		$schema->createSchema();
42
	}
43
44
	public function getEntityManager(): EntityManager {
45
		return $this->factory->getEntityManager();
46
	}
47
48
}
49