Amock::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Amock;
4
5
use PHPUnit\Framework\TestCase;
6
7
class Amock
8
{
9
    private $loader;
10
11
    private $parser;
12
13
    private $stubConfiguration;
14
15 11
    public static function create(Configuration $config, TestCase $testCase): Amock
16
    {
17 11
        $loader = Loader\LoaderFactory::create(
18 11
            $config->getSourceType(),
19 11
            $config->getValue()
20
        );
21
22 10
        $parser = Parser\ParserFactory::create($config->getType());
23
24 9
        return new Amock($loader, $parser, new StubConfiguration($testCase));
25
    }
26
27 10
    public function __construct(
28
        Loader\Loader $loader,
29
        Parser\Parser $parser,
30
        StubConfiguration $stubConfiguration
31
    ) {
32 10
        $this->loader = $loader;
33 10
        $this->parser = $parser;
34 10
        $this->stubConfiguration = $stubConfiguration;
35 10
    }
36
37 10
    public function get(string $objectId)
38
    {
39 10
        $this->parser->parse($this->loader->get());
40 10
        $this->stubConfiguration->setStubConfigurationArray($this->parser[$objectId]);
41
42 10
        return $this->stubConfiguration->getStub();
43
    }
44
}
45