| Conditions | 5 |
| Paths | 12 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | 6 | private function doNgrams($data, $n = 1, $cyclic = true) |
|
| 41 | { |
||
| 42 | 6 | $dataLength = count($data); |
|
| 43 | |||
| 44 | 6 | $n = $n > $dataLength ? $dataLength : $n; |
|
| 45 | |||
| 46 | 6 | $length = (false === $cyclic ? $dataLength - $n + 1 : $dataLength); |
|
| 47 | |||
| 48 | 6 | for ($j = 0; $j < $length; $j++) { |
|
| 49 | 6 | $ngrams = []; |
|
| 50 | 6 | for ($i = $j; $i < $n + $j; $i++) { |
|
| 51 | 6 | $ngrams[] = $data[$i%$dataLength]; |
|
| 52 | } |
||
| 53 | 6 | yield $ngrams; |
|
| 54 | } |
||
| 55 | 6 | } |
|
| 56 | } |
||
| 57 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.