Completed
Pull Request — master (#1)
by Tim
65:22
created

DatabaseSchema   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A createSchema() 0 2 1
A getClassMetaData() 0 2 1
A __construct() 0 2 1
A dropSchema() 0 2 1
A getSchemaTool() 0 2 1
1
<?php
2
3
declare( strict_types = 1);
4
5
namespace WMDE\Fundraising\AddressChangeContext\Tests;
6
7
use Doctrine\ORM\EntityManager;
8
use Doctrine\ORM\Tools\SchemaTool;
9
10
class DatabaseSchema {
11
	private $entityManager;
12
13
	public function __construct( EntityManager $entityManager ) {
14
		$this->entityManager = $entityManager;
15
	}
16
17
	public function createSchema() {
18
		$this->getSchemaTool()->createSchema( $this->getClassMetaData() );
19
	}
20
21
	public function dropSchema(): void {
22
		$this->getSchemaTool()->dropSchema( $this->getClassMetaData() );
23
	}
24
25
	private function getSchemaTool(): SchemaTool {
26
		return new SchemaTool( $this->entityManager );
27
	}
28
29
	private function getClassMetaData(): array {
30
		return $this->entityManager->getMetadataFactory()->getAllMetadata();
31
	}
32
}