Passed
Push — master ( 1e7555...a49478 )
by Pol
03:09
created

NGrams::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace drupol\phpermutations\Iterators;
4
5
/**
6
 * Class NGrams.
7
 */
8
class NGrams extends Shift implements \Iterator, \Countable
9
{
10
    /**
11
     * @var
12
     */
13
    protected $currentValue;
14
15
    /**
16
     * NGrams constructor.
17
     *
18
     * @param array $dataset
19
     *                       The dataset
20
     * @param int   $length
21
     *                       The shift length
22
     */
23 4
    public function __construct(array $dataset = [], $length = 1)
24
    {
25 4
        parent::__construct($dataset, $length);
26 4
        $this->currentValue = array_slice(($this->getDataset()), 0, $length);
27 4
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 4
    public function next()
33
    {
34 4
        parent::next();
35 4
        $this->currentValue = array_slice($this->current, 0, $this->getLength());
36 4
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function rewind()
42
    {
43
        parent::rewind();
44
        $this->currentValue = array_slice($this->current, 0, $this->getLength());
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 4
    public function current()
51
    {
52 4
        return $this->currentValue;
53
    }
54
}
55