Passed
Pull Request — master (#2157)
by
unknown
62:16
created

ChoiceFactory::getAmountOption()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 7.049

Importance

Changes 0
Metric Value
cc 7
eloc 13
nc 7
nop 0
dl 0
loc 15
ccs 9
cts 10
cp 0.9
crap 7.049
rs 8.8333
c 0
b 0
f 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\Factories;
6
7
use Symfony\Component\HttpFoundation\RedirectResponse;
8
use Symfony\Component\HttpFoundation\Request;
9
use WMDE\Euro\Euro;
10
use WMDE\Fundraising\Frontend\BucketTesting\FeatureToggle;
11
use WMDE\Fundraising\Frontend\Infrastructure\UrlGenerator;
12
13
/**
14
 * Factory for generating classes whose implementations differ due to A/B testing.
15
 *
16
 * @license GPL-2.0-or-later
17
 */
18
class ChoiceFactory {
19
20 100
	private $featureToggle;
21 100
22 100
	public function __construct( FeatureToggle $featureToggle ) {
23
		$this->featureToggle = $featureToggle;
24 14
	}
25
26 14
	public function getAddressType(): ?string {
27 10
		if ( $this->featureToggle->featureIsActive( 'campaigns.address_type.no_preselection' ) ) {
28
			return null;
29 4
		} elseif ( $this->featureToggle->featureIsActive( 'campaigns.address_type.preselection' ) ) {
30 4
			return 'person';
31
		}
32
		throw new UnknownChoiceDefinition( 'Address type configuration failure.' );
33
	}
34
}
35