Passed
Push — master ( 7ca88e...9f8c4e )
by Mariano
04:25
created

ArrayToExpectationConverterLocator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Mcustiel\Phiremock\Common\Utils;
4
5
use Mcustiel\Phiremock\Common\Utils\V1\Factory as FactoryV1;
6
use Mcustiel\Phiremock\Common\Utils\V2\Factory as FactoryV2;
7
8
class ArrayToExpectationConverterLocator
9
{
10
    /** @var FactoryV1 */
11
    private $factoryV1;
12
13
    /** @var FactoryV2 */
14
    private $factoryV2;
15
16 24
    public function __construct(FactoryV1 $factoryV1, FactoryV2 $factoryV2)
17
    {
18 24
        $this->factoryV1 = $factoryV1;
19 24
        $this->factoryV2 = $factoryV2;
20 24
    }
21
22 24
    public function locate(array $expectationArray): ArrayToExpectationConverter
23
    {
24 24
        if (isset($expectationArray['version'])) {
25 15
            switch ($expectationArray['version']) {
26 15
                case '1':
27
                    return $this->factoryV1->createArrayToExpectationConverter();
28 15
                case '2':
29 15
                    return $this->factoryV2->createArrayToExpectationConverter();
30
            }
31
            throw new \Exception(sprintf('Unimplemented configuration version: %s', $expectationArray['version']));
32
        }
33
34 9
        return $this->factoryV1->createArrayToExpectationConverter();
35
    }
36
}
37