Completed
Pull Request — dev (#17)
by Ben
11:05
created

Collection::convert()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
eloc 7
nc 3
nop 3
1
<?php
2
3
namespace Benrowe\Laravel\Config\Modifiers;
4
5
use Illuminate\Support\Collection as BaseCollection;
6
use Benrowe\Laravel\Config\Modifiers\Modifier;
7
8
/**
9
 *
10
 */
11
class Collection extends BaseCollection
12
{
13
    private $keys = [];
14
    /**
15
     * Convert the value based on the supplied modifiers
16
     *
17
     * @param  string $key       [description]
18
     * @param  mixed $value     [description]
19
     * @param  string $direction [description]
20
     * @return mixed            [description]
21
     */
22
    public function convert($key, $value, $direction = Modifier::DIRECTION_TO)
23
    {
24
        $method = 'convert'.ucfirst($direction);
25
        foreach ($this->items as $modifier) {
26
            if ($modifier->canHandle($value, $direction)) {
27
                $this->keys = $key;
0 ignored issues
show
Documentation Bug introduced by
It seems like $key of type string is incompatible with the declared type array of property $keys.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
                return $modifier->$method($value);
29
            }
30
        }
31
        return $value;
32
    }
33
}
34