CallbackConverter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A convert() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of plumphp/plum.
5
 *
6
 * (c) Florian Eckerstorfer <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Plum\Plum\Converter;
12
13
/**
14
 * CallbackConverter.
15
 *
16
 * @author    Florian Eckerstorfer <[email protected]>
17
 * @copyright 2014-2016 Florian Eckerstorfer
18
 */
19
class CallbackConverter implements ConverterInterface
20
{
21
    /** @var callable */
22
    private $callback;
23
24
    /**
25
     * @param callable $callback
26
     */
27 1
    public function __construct($callback)
28
    {
29 1
        $this->callback = $callback;
30 1
    }
31
32
    /**
33
     * @param mixed $item
34
     *
35
     * @return mixed
36
     */
37 1
    public function convert($item)
38
    {
39 1
        return call_user_func($this->callback, $item);
40
    }
41
}
42