CallableTransformer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 4
c 3
b 0
f 0
dl 0
loc 31
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A exec() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of YaEtl
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\YaEtl\Transformers;
11
12
use fab2s\NodalFlow\NodalFlowException;
13
use fab2s\NodalFlow\Nodes\PayloadNodeAbstract;
14
15
/**
16
 * Class CallableTransformer
17
 */
18
class CallableTransformer extends PayloadNodeAbstract implements TransformerInterface
19
{
20
    /**
21
     * The underlying executable or traversable Payload
22
     *
23
     * @var callable
24
     */
25
    protected $payload;
26
27
    /**
28
     * Instantiate the transformer
29
     *
30
     * @param callable $payload
31
     *
32
     * @throws NodalFlowException
33
     */
34
    public function __construct(callable $payload)
35
    {
36
        parent::__construct($payload, true, false);
37
    }
38
39
    /**
40
     * Execute the callable payload
41
     *
42
     * @param mixed $param the record
43
     *
44
     * @return mixed
45
     */
46
    public function exec($param = null)
47
    {
48
        return \call_user_func($this->payload, $param);
49
    }
50
}
51