Code Duplication    Length = 35-35 lines in 2 locations

src/Flow/File/CopyFiles.php 1 location

@@ 23-57 (lines=35) @@
20
use Graze\DataNode\NodeInterface;
21
use InvalidArgumentException;
22
23
class CopyFiles extends AbstractFlow
24
{
25
    /**
26
     * @var FileNode
27
     */
28
    private $targetDirectory;
29
30
    /**
31
     * MoveFiles constructor.
32
     *
33
     * @param FileNode $targetDirectory
34
     */
35
    public function __construct(FileNode $targetDirectory)
36
    {
37
        if (substr($targetDirectory, -1) != '/') {
38
            throw new InvalidArgumentException("The targetDirectory: '$targetDirectory' does not end in '/'");
39
        }
40
        $this->targetDirectory = $targetDirectory;
41
    }
42
43
    /**
44
     * @param NodeInterface $node
45
     *
46
     * @return NodeInterface
47
     */
48
    public function flow(NodeInterface $node)
49
    {
50
        if (!($node instanceof FileNodeCollectionInterface)) {
51
            throw new InvalidArgumentException("Node: $node should be an instance of FileNodeCollectionInterface");
52
        }
53
54
        $each = new Each(new CopyFile($this->targetDirectory));
55
        return $each->flow($node);
56
    }
57
}
58

src/Flow/File/MoveFiles.php 1 location

@@ 23-57 (lines=35) @@
20
use Graze\DataNode\NodeInterface;
21
use InvalidArgumentException;
22
23
class MoveFiles extends AbstractFlow
24
{
25
    /**
26
     * @var FileNode
27
     */
28
    private $targetDirectory;
29
30
    /**
31
     * MoveFiles constructor.
32
     *
33
     * @param FileNode $targetDirectory
34
     */
35
    public function __construct(FileNode $targetDirectory)
36
    {
37
        if (substr($targetDirectory, -1) != '/') {
38
            throw new InvalidArgumentException("The targetDirectory: '$targetDirectory' does not end in '/'");
39
        }
40
        $this->targetDirectory = $targetDirectory;
41
    }
42
43
    /**
44
     * @param NodeInterface $node
45
     *
46
     * @return NodeInterface
47
     */
48
    public function flow(NodeInterface $node)
49
    {
50
        if (!($node instanceof FileNodeCollectionInterface)) {
51
            throw new InvalidArgumentException("Node: $node should be an instance of FileNodeCollectionInterface");
52
        }
53
54
        $each = new Each(new MoveFile($this->targetDirectory));
55
        return $each->flow($node);
56
    }
57
}
58