| Conditions | 5 |
| Paths | 12 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | private function doNgrams($data, $n = 1, $cyclic = true) |
||
| 41 | { |
||
| 42 | $dataLength = count($data); |
||
| 43 | |||
| 44 | $n = $n > $dataLength ? $dataLength : $n; |
||
| 45 | |||
| 46 | $length = (false === $cyclic ? $dataLength - $n + 1 : $dataLength); |
||
| 47 | |||
| 48 | for ($j = 0; $j < $length; $j++) { |
||
| 49 | $ngrams = []; |
||
| 50 | for ($i = $j; $i < $n + $j; $i++) { |
||
| 51 | $ngrams[] = $data[$i%$dataLength]; |
||
| 52 | } |
||
| 53 | yield $ngrams; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 |