Completed
Push — dev ( e55f7a...57e45c )
by Ben
11s
created

Collection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A convert() 0 11 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
 *
15
 */
16
class Collection extends BaseCollection
17
{
18
    private $keys = [];
19
    /**
20
     * Convert the value based on the supplied modifiers
21
     *
22
     * @param  string $key       [description]
23
     * @param  mixed $value     [description]
24
     * @param  string $direction [description]
25
     * @return mixed            [description]
26
     */
27
    public function convert($key, $value, $direction = Modifier::DIRECTION_TO)
28
    {
29
        $method = 'convert'.ucfirst($direction);
30
        foreach ($this->items as $modifier) {
31
            if ($modifier->canHandle($value, $direction)) {
32
                $this->keys[] = $key;
33
                return $modifier->$method($value);
34
            }
35
        }
36
        return $value;
37
    }
38
}
39