Passed
Push — master ( fd93c6...4910da )
by Tomáš
04:38
created

PriceCalculatorFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 38
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A __construct() 0 3 1
A getClass() 0 3 1
A setClass() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Sunfox\PriceCalculator;
4
5
final class PriceCalculatorFactory
6
{
7
	/**
8
	 * @var string
9
	 */
10
	private $class;
11
12
	/**
13
	 * Accepts class name with full namespace.
14
	 */
15 1
	public function __construct(string $class = PriceCalculator::class)
16
	{
17 1
		$this->class = $class;
18 1
	}
19
20
	/**
21
	 * Create and return PriceCalculator instance.
22
	 */
23
	public function create(): IPriceCalculator
24
	{
25 1
		return new $this->class;
26
	}
27
28
	/**
29
	 * Get class name.
30
	 */
31
	public function getClass(): string
32
	{
33 1
		return $this->class;
34
	}
35
36
	/**
37
	 * Set class name.
38
	 */
39 1
	public function setClass(string $class): self
40
	{
41 1
		$this->class = $class;
42 1
		return $this;
43
	}
44
}
45