Base::getManager()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 9.4285
1
<?php
2
3
namespace Iris\Mapping;
4
5
abstract class Base
6
{
7
    private static $instances = array();
8
9
    private $manager;
10
11 8
    protected function __construct()
12
    {
13 8
    }
14
15
    protected function __clone()
16
    {
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 20
    public static function getInstance()
23
    {
24 20
        $class = static::class;
25 20
        if (!isset(self::$instances[$class])) {
26 8
            self::$instances[$class] = new static();
27 8
        }
28 20
        return self::$instances[$class];
29
    }
30
31
    /**
32
     * @return \Iris\Manager
33
     */
34 1
    public function getManager()
35
    {
36 1
        $this->manager || $this->setManager(\Iris\Manager::getInstance());
37 1
        return $this->manager;
38
    }
39
40
    /**
41
     * @param \Iris\Manager $manager
42
     * @return Base
43
     */
44 4
    public function setManager(\Iris\Manager $manager)
45
    {
46 4
        $this->manager = $manager;
47 4
        return $this;
48
    }
49
50
    /**
51
     * Converts an array of infrastructure to a business object.
52
     * Here IRIS receives external shop data and converts it to its custom Transfer Object
53
     *
54
     * @param array $externalData
55
     * @return \Iris\Transfer\Catalog\ConfigCollection
56
     */
57
    abstract public function assign(array $externalData);
58
59
    /**
60
     * Converts a business object to an array.
61
     * Here IRIS prepares data for external shop from its custom Transfer objects
62
     *
63
     * @param $internalData Transfer object
64
     * @return array
65
     */
66
    abstract public function map($internalData);
67
}
68