ArrayLoader::walkAllLeaves()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the ConfigCacheBundle package.
5
 *
6
 * Copyright (c) 2015-2016 Yahoo Japan Corporation
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace YahooJapan\ConfigCacheBundle\ConfigCache\Loader;
13
14
/**
15
 * ArrayLoader loads an array converting user configurations.
16
 */
17
abstract class ArrayLoader implements ArrayLoaderInterface
18
{
19
    // to convert method name
20
    protected $internalMethod = 'walkInternal';
21
22
    /**
23
     * Loads an array of resource.
24
     *
25
     * @param array $resource an array loaded from the file.
26
     *
27
     * @return array
28
     */
29 6
    public function load(array $resource)
30
    {
31 6
        $this->walkAllLeaves($resource);
32
33 6
        return $resource;
34
    }
35
36
    /**
37
     * Walks all leaves converting.
38
     *
39
     * @param array &$config
40
     *
41
     * @return void
42
     */
43 6
    protected function walkAllLeaves(&$config)
44
    {
45 6
        array_walk_recursive($config, array($this, $this->getInternalMethod()));
46 6
    }
47
48
    /**
49
     * Walks all leaves converting internal processing.
50
     *
51
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
52
     * @note  implement child class
53
     * @param string &$value
54
     * @param string $nouse
55
     *
56
     * @return void
57
     */
58 1
    protected function walkInternal(&$value, $nouse)
0 ignored issues
show
Unused Code introduced by
The parameter $nouse is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60 1
    }
61
62
    /**
63
     * Gets a transform internal method.
64
     *
65
     * @return string
66
     */
67 4
    protected function getInternalMethod()
68
    {
69 4
        return $this->internalMethod;
70
    }
71
}
72