Collection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A convert() 0 12 3
1
<?php
2
3
/**
4
 * @author Ben Rowe <[email protected]>
5
 * @license    http://www.opensource.org/licenses/mit-license.html MIT License
6
 */
7
8
namespace Benrowe\Laravel\Config\Modifiers;
9
10
use Benrowe\Laravel\Config\Modifiers\Modifier;
11
use Illuminate\Support\Collection as BaseCollection;
12
13
/**
14
 * Modifier collection
15
 *
16
 * @package Benrowe\Laravel\Config\Modifiers
17
 */
18
class Collection extends BaseCollection
19
{
20
    /**
21
     * @var array list of keys that have been modified
22
     */
23
    private $keys = [];
24
    
25
    /**
26
     * Convert the value based on the supplied modifiers
27
     *
28
     * @param  string $key       [description]
29
     * @param  mixed $value     [description]
30
     * @param  string $direction [description]
31
     * @return mixed            [description]
32
     */
33
    public function convert($key, $value, $direction = Modifier::DIRECTION_TO)
34
    {
35
        $convertMethod = 'convert'.ucfirst($direction);
36
        $canMethod = 'canHandle'.ucfirst($direction);
37
        foreach ($this->items as $modifier) {
38
            if ($modifier->$canMethod($value)) {
39
                $this->keys[] = $key;
40
                return $modifier->$convertMethod($value);
41
            }
42
        }
43
        return $value;
44
    }
45
}
46