SchemaCreator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

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\Mapping\ClassMetadata;
9
use Doctrine\ORM\Tools\SchemaTool;
10
11
class SchemaCreator {
12
13
	private EntityManager $entityManager;
14
15
	public function __construct( EntityManager $entityManager ) {
16
		$this->entityManager = $entityManager;
17
	}
18
19
	public function createSchema(): void {
20
		$this->getSchemaTool()->createSchema( $this->getClassMetaData() );
21
	}
22
23
	public function dropSchema(): void {
24
		$this->getSchemaTool()->dropSchema( $this->getClassMetaData() );
25
	}
26
27
	private function getSchemaTool(): SchemaTool {
28
		return new SchemaTool( $this->entityManager );
29
	}
30
31
	/**
32
	 * @return array<int, ClassMetadata>
33
	 */
34
	private function getClassMetaData(): array {
35
		return $this->entityManager->getMetadataFactory()->getAllMetadata();
36
	}
37
}
38