| Conditions | 5 |
| Paths | 12 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 56 | 12 | private function doNgrams($data, $n = 1, $cyclic = true) |
|
| 57 | { |
||
| 58 | 12 | $dataLength = count($data); |
|
| 59 | 12 | $n = $n > $dataLength ? $dataLength : $n; |
|
| 60 | 12 | $length = (false === $cyclic ? $dataLength - $n + 1 : $dataLength); |
|
| 61 | |||
| 62 | 12 | for ($j = 0; $j < $length; $j++) { |
|
| 63 | 12 | $ngrams = []; |
|
| 64 | 12 | for ($i = $j; $i < $n + $j; $i++) { |
|
| 65 | 12 | $ngrams[] = $data[$i%$dataLength]; |
|
| 66 | } |
||
| 67 | 12 | yield $ngrams; |
|
| 68 | } |
||
| 69 | 12 | } |
|
| 70 | } |
||
| 71 |