WriterPipe   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
c 6
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createWriter() 0 17 4
1
<?php
2
3
/**
4
 * This file is part of plumphp/plum.
5
 *
6
 * (c) Florian Eckerstorfer <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Plum\Plum\Pipe;
12
13
use InvalidArgumentException;
14
use Plum\Plum\Writer\WriterInterface;
15
16
/**
17
 * WriterPipe.
18
 *
19
 * @author    Florian Eckerstorfer
20
 * @copyright 2014-2016 Florian Eckerstorfer
21
 */
22
class WriterPipe extends AbstractPipe
23
{
24
    /**
25
     * @param WriterInterface|array $element
26
     *
27
     * @return WriterPipe
28
     */
29 6
    public static function createWriter($element)
30
    {
31 6
        if ($element instanceof WriterInterface) {
32 1
            $writer = $element;
33 6
        } elseif (isset($element['writer']) && $element['writer'] instanceof WriterInterface) {
34 3
            $writer = $element['writer'];
35 3
        } else {
36 2
            throw new InvalidArgumentException('Workflow::addWriter() must be called with either an instance of '.
37 2
                                               '"Plum\Plum\Writer\WriterInterface" or with an array that contains '.
38 2
                                               '"writer".');
39
        }
40
41 4
        $pipe         = new self($element);
42 4
        $pipe->writer = $writer;
43
44 4
        return $pipe;
45
    }
46
}
47