Completed
Push — master ( aecae1...06dd79 )
by Sébastien
01:49
created

LinkedCallableFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createCallable() 0 12 3
1
<?php
2
3
namespace Bdf\Pipeline\CallableFactory;
4
5
use Bdf\Pipeline\CallableFactoryInterface;
6
7
/**
8
 * LinkedCallableFactory
9
 *
10
 * @author Sébastien Tanneux
11
 */
12
class LinkedCallableFactory implements CallableFactoryInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function createCallable(array $pipes, callable $outlet = null)
18
    {
19
        if ($outlet !== null) {
20
            $pipes[] = $outlet;
21
        }
22
23
        return function($payload) use($pipes) {
24
            foreach ($pipes as $pipe) {
25
                $payload = $pipe($payload);
26
            }
27
28
            return $payload;
29
        };
30
    }
31
}
32