Conditions | 4 |
Paths | 8 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
58 | 12 | private function doNgrams($data, $n = 1, $cyclic = true) |
|
59 | { |
||
60 | 12 | $dataLength = count($data); |
|
61 | 12 | $n = $n > $dataLength ? $dataLength : $n; |
|
62 | 12 | $length = (false === $cyclic ? $dataLength - $n + 1 : $dataLength); |
|
63 | |||
64 | 12 | $shift = new Shift($data); |
|
65 | |||
66 | 12 | for ($j = 0; $j < $length; $j++) { |
|
67 | 12 | yield array_slice($shift->current(), 0, $n); |
|
68 | 12 | $shift->rewind(); |
|
69 | } |
||
70 | 12 | } |
|
71 | } |
||
72 |