Completed
Pull Request — master (#10)
by Gabriel
60:20
created

SchemaCreator::__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 SchemaCreator {
11
12
	private EntityManager $entityManager;
13
14
	public function __construct( EntityManager $entityManager ) {
15
		$this->entityManager = $entityManager;
16
	}
17
18
	public function createSchema(): void {
19
		$this->getSchemaTool()->createSchema( $this->getClassMetaData() );
20
	}
21
22
	public function dropSchema(): void {
23
		$this->getSchemaTool()->dropSchema( $this->getClassMetaData() );
24
	}
25
26
	private function getSchemaTool(): SchemaTool {
27
		return new SchemaTool( $this->entityManager );
28
	}
29
30
	private function getClassMetaData(): array {
31
		return $this->entityManager->getMetadataFactory()->getAllMetadata();
32
	}
33
}