Completed
Push — master ( b5c840...3d5461 )
by Marcus
04:46
created

RegistryLoader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 59
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A load() 0 4 1
A getRegistryKey() 0 4 1
A getRegistryProcessor() 0 4 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Loaders\RegistryLoader
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2019 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Loaders;
22
23
use TechDivision\Import\Utils\RegistryKeys;
24
use TechDivision\Import\Services\RegistryProcessorInterface;
25
26
/**
27
 * Generic loader for data from the registry.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2019 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import
33
 * @link      http://www.techdivision.com
34
 */
35
class RegistryLoader implements LoaderInterface
36
{
37
38
    /**
39
     * The registry processor instance.
40
     *
41
     * @var \TechDivision\Import\Services\RegistryProcessorInterface
42
     */
43
    protected $registryProcessor;
44
45
    /**
46
     * Registry key to load the data with.
47
     *
48
     * @var string
49
     */
50
    protected $registryKey;
51
52
    /**
53
     * Construct that initializes the iterator with the registry processor instance.
54
     *
55
     * @param \TechDivision\Import\Services\RegistryProcessorInterface $registryProcessor The registry processor instance
56
     * @param string                                                   $registryKey       The registry key to load the data with
57
     */
58
    public function __construct(RegistryProcessorInterface $registryProcessor, $registryKey = RegistryKeys::STATUS)
59
    {
60
        $this->registryProcessor = $registryProcessor;
61
        $this->registryKey = $registryKey;
62
    }
63
64
    /**
65
     * Loads and returns data.
66
     *
67
     * @return \ArrayAccess The array with the data
68
     */
69
    public function load()
70
    {
71
        return $this->getRegistryProcessor()->load($this->getRegistryKey());
72
    }
73
74
    /**
75
     * Return's the registry key to load the data with.
76
     *
77
     * @return string The registry key
78
     */
79
    protected function getRegistryKey()
80
    {
81
        return $this->registryKey;
82
    }
83
84
    /**
85
     * Return's the registry processor instance.
86
     *
87
     * @return \TechDivision\Import\Services\RegistryProcessorInterface The processor instance
88
     */
89
    protected function getRegistryProcessor()
90
    {
91
        return $this->registryProcessor;
92
    }
93
}
94