Manager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 64
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFactory() 0 8 2
A setFactory() 0 5 1
A create() 0 7 1
A rebuild() 0 6 1
A getHydrator() 0 4 1
1
<?php
2
3
namespace GFG\DTOContext;
4
5
use GFG\DTOContext\DataWrapper;
6
use GFG\DTOContext\Factory;
7
8
class Manager
9
{
10
    /**
11
     * Factory responsible to create the ContextObject
12
     *
13
     * @var Factory\FactoryInterface
14
     */
15
    private static $factory;
16
17
    /**
18
     * Get the current factory
19
     *
20
     * @return Factory\FactoryInterface
21
     */
22 5
    public function getFactory()
23
    {
24 5
        if (!self::$factory) {
25 1
            throw new \RuntimeException('Factory not set');
26
        }
27
28 4
        return self::$factory;
29
    }
30
     
31
    /**
32
     * Sets a new factory class
33
     *
34
     * @param Factory\FactoryInterface
35
     * @return Manager
36
     */
37 4
    public function setFactory(Factory\FactoryInterface $factory)
38
    {
39 4
        self::$factory = $factory;
40 4
        return $this;
41
    }
42
43
    /**
44
     * @see Factory\FactoryInterface::build
45
     */
46 1
    public function create(
47
        $contextName,
48
        DataWrapper\DataWrapperInterface $dataWrapper
49
    ) {
50 1
            return $this->getFactory()
51 1
                ->build($contextName, $dataWrapper);
52
    }
53
54
    /**
55
     * @see Factory\FactoryInterface::rebuild
56
     */
57 1
    public function rebuild(
58
        array $rawData,
59
        Factory\HydratorInterface $hydrator
60
    ) {
61 1
        return $this->getFactory()->rebuild($rawData, $hydrator);
62
    }
63
64
    /**
65
     * @see Factory\FactoryInterface::getHydrator
66
     */
67 1
    public function getHydrator()
68
    {
69 1
        return $this->getFactory()->getHydrator();
70
    }
71
}
72