Head::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\Node\LocalFile;
17
use Graze\DataFlow\Flow\InvokeTrait;
18
use Graze\DataFlow\FlowInterface;
19
use Graze\DataNode\NodeInterface;
20
use InvalidArgumentException;
21
22 View Code Duplication
class Head extends \Graze\DataFile\Modify\Head 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...
23
{
24
    use InvokeTrait;
25
26
    /**
27
     * @param string $lines   Number of lines to tail (accepts +/- modifiers)
28
     * @param array  $options List of options:
29
     *                        -postfix <string> (Default: tail)
30
     *                        -keepOldFile <bool> (Default: true)
31
     */
32 4
    public function __construct($lines, array $options = [])
33
    {
34 4
        $this->lines = $lines;
35 4
        $this->options = $options;
36 4
    }
37
38
    /**
39
     * Run a 'flow' through the handler
40
     *
41
     * @param NodeInterface $node
42
     *
43
     * @return LocalFile
44
     */
45 4
    public function flow(NodeInterface $node)
46
    {
47 4
        if (!($node instanceof LocalFile)) {
48 1
            throw new InvalidArgumentException("Node: $node should be an instance of LocalFile");
49
        }
50
51 3
        return $this->head($node, $this->lines, $this->options);
52
    }
53
}
54