LazyLoader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 37
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResourceFile() 0 4 1
A doInitialize() 0 5 1
A handleRawData() 0 4 1
1
<?php
2
/*
3
 * This file is part of the Slince/China package.
4
 *
5
 * (c) Slince <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace China\Common\ResourceLoader;
12
13
use China\Common\ResourceFile;
14
use Doctrine\Common\Collections\AbstractLazyCollection;
15
use Doctrine\Common\Collections\ArrayCollection;
16
use Slince\Config\Config;
17
18
class LazyLoader extends AbstractLazyCollection implements ResourceLoaderInterface
19
{
20
    /**
21
     * @var ResourceFile
22
     */
23
    protected $resourceFile;
24
25
    public function __construct(ResourceFile $resourceFile)
26
    {
27
        $this->resourceFile = $resourceFile;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getResourceFile()
34
    {
35
        return $this->resourceFile;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function doInitialize()
42
    {
43
        $rawData = (new Config($this->resourceFile->getPathname()))->toArray();
44
        $this->collection = new ArrayCollection($this->handleRawData($rawData));
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function handleRawData($data)
51
    {
52
        return $data;
53
    }
54
}