Base::__clone()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
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