Passed
Push — master ( d95ec3...cc469b )
by Jelle
04:26
created

Callback::reverse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * @file
4
 * Contains TheSportsDb\PropertyMapper\Transformer\Callback.
5
 */
6
namespace TheSportsDb\PropertyMapper\Transformer;
7
8
use FastNorth\PropertyMapper\Transformer\TransformerInterface;
9
10
/**
11
 * Callback transformer
12
 *
13
 * @author Jelle Sebreghts
14
 */
15
class Callback implements TransformerInterface
16
{
17
    /**
18
     * Transforming method.
19
     *
20
     * @param callable
21
     */
22
    private $transform;
23
24
    /**
25
     * Reversing method.
26
     *
27
     * @param callable
28
     */
29
    private $reverse;
30
31
    /**
32
     * Constructor.
33
     *
34
     * @param callable $transform
35
     * @param callable $reverse
36
     */
37
    public function __construct(callable $transform, callable $reverse)
38
    {
39
        $this->transform = $transform;
40
        $this->reverse   = $reverse;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function transform($value, $context)
47
    {
48 1
        return call_user_func_array($this->transform, [$value, $context]);
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    public function reverse($value, $context)
55
    {
56 1
        return call_user_func_array($this->reverse, [$value, $context]);
57
    }
58
}
59