CallableTransformer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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