1: <?php
2:
3: /**
4: * Copyright 2015, Eduardo Trujillo
5: *
6: * For the full copyright and license information, please view the LICENSE
7: * file that was distributed with this source code.
8: *
9: * This file is part of the Nucleus package
10: */
11:
12: namespace Chromabits\Nucleus\Transformation;
13:
14: use Chromabits\Nucleus\Support\Std;
15: use Chromabits\Nucleus\Transformation\Interfaces\TransformInterface;
16: use Closure;
17:
18: /**
19: * Class ClosureTransform.
20: *
21: * A transform that wraps a closure.
22: *
23: * @author Eduardo Trujillo <ed@chromabits.com>
24: * @package Chromabits\Nucleus\Support
25: */
26: class ClosureTransform implements TransformInterface
27: {
28: /**
29: * @var Closure
30: */
31: protected $inner;
32:
33: /**
34: * Construct an instance of a ClosureTransform.
35: *
36: * @param Closure $inner
37: */
38: public function __construct(Closure $inner)
39: {
40: $this->inner = $inner;
41: }
42:
43: /**
44: * Execute the transform.
45: *
46: * @param array $input
47: *
48: * @return array
49: */
50: public function run(array $input)
51: {
52: return Std::call($this->inner, $input);
53: }
54: }
55: