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\Transformation\Interfaces\TransformInterface;
15:
16: /**
17: * Class ExtendTransform.
18: *
19: * A transform that takes the input and merges it with another array. The
20: * provided array can override the input fields, hence the name extension.
21: *
22: * @author Eduardo Trujillo <ed@chromabits.com>
23: * @package Chromabits\Nucleus\Support\Transforms
24: */
25: class ExtendTransform implements TransformInterface
26: {
27: /**
28: * @var array
29: */
30: protected $extension;
31:
32: /**
33: * Construct an instance of a ExtendTransform.
34: *
35: * @param array $extension
36: */
37: public function __construct(array $extension)
38: {
39: $this->extension = $extension;
40: }
41:
42: /**
43: * Execute the transform.
44: *
45: * @param array $input
46: *
47: * @return array
48: */
49: public function run(array $input)
50: {
51: return array_merge($input, $this->extension);
52: }
53: }
54: