Completed
Push — master ( 247b53...16b162 )
by Jeroen De
03:24
created

MapsTestFactory::getImageRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Tests;
6
7
use Maps\DataAccess\ImageRepository;
8
use Maps\MapsFactory;
9
use Maps\Tests\TestDoubles\InMemoryImageRepository;
10
11
class MapsTestFactory extends MapsFactory {
12
13
	/**
14
	 * Can be exposed via getter type in PHP 7.4+
15
	 * @var InMemoryImageRepository
16
	 */
17
	public $imageRepo;
18
19
	/**
20
	 * Initializes a new test instance, updates the global instance used by production code and returns it.
21
	 */
22
	public static function newTestInstance(): self {
23
		self::$globalInstance = self::newDefault();
24
25
		self::$globalInstance->imageRepo = new InMemoryImageRepository();
26
27
		return self::$globalInstance;
28
	}
29
30
	public function getImageRepository(): ImageRepository {
31
		return $this->imageRepo;
32
	}
33
34
}
35