IdGeneratorFactory::getIdGenerator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace IdGenerator;
6
7
use IdGenerator\PackagePrivate\DatabaseIdGenerator;
8
use IdGenerator\PackagePrivate\PagePropsIdDatabase;
9
use Wikimedia\Rdbms\ILoadBalancer;
10
11
class IdGeneratorFactory {
12
13
	private $generator;
14
15 1
	public function getIdGenerator( ILoadBalancer $loadBalancer ): IdGenerator {
16 1
		if ( $this->generator === null ) {
17 1
			$this->generator = new DatabaseIdGenerator(
18 1
				$loadBalancer,
19 1
				new PagePropsIdDatabase()
20
			);
21
		}
22
23 1
		return $this->generator;
24
	}
25
26
}
27