Merge::flow()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of graze/data-flow
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-flow/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-flow
12
 */
13
14
namespace Graze\DataFlow\Flow\File;
15
16
use Graze\DataFile\Modify\Contract\MergeFiles;
17
use Graze\DataFile\Node\FileNodeCollectionInterface;
18
use Graze\DataFile\Node\FileNodeInterface;
19
use Graze\DataFlow\Flow\InvokeTrait;
20
use Graze\DataFlow\FlowInterface;
21
use Graze\DataNode\NodeInterface;
22
23 View Code Duplication
class Merge extends MergeFiles implements FlowInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    use InvokeTrait;
26
27
    /**
28
     * @var FileNodeInterface
29
     */
30
    private $file;
31
32
    /**
33
     * @param FileNodeInterface $file
34
     * @param array             $options
35
     */
36 4
    public function __construct(
37
        FileNodeInterface $file,
38
        array $options = []
39
    ) {
40 4
        $this->file = $file;
41 4
        $this->options = $options;
42 4
    }
43
44
    /**
45
     * Add files from a local Directory
46
     *
47
     * @param NodeInterface $node
48
     *
49
     * @return FileNodeInterface
50
     */
51 4
    public function flow(NodeInterface $node)
52
    {
53 4
        if (!($node instanceof FileNodeCollectionInterface)) {
54 1
            throw new \InvalidArgumentException("The supplied $node is not a FileNodeCollectionInterface");
55
        }
56
57 3
        return $this->contract($node, $this->file, $this->options);
58
    }
59
}
60