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

DatabaseSchema::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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