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

SchemaCreator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassMetaData() 0 2 1
A createSchema() 0 2 1
A getSchemaTool() 0 2 1
A __construct() 0 2 1
A dropSchema() 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 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
}