Avoid variables with short names like $n. Configured minimum length is 3.
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.
Avoid variables with short names like $n. Configured minimum length is 3.
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.
Loading history...
31
{
32
12
$ngrams = [];
33
34
12
if (is_string($data)) {
35
6
foreach ($this->doNgrams(str_split($data), $n, $cyclic) as $item) {
36
6
yield implode('', $item);
37
}
38
}
39
40
12
if (is_array($data)) {
41
8
foreach ($this->doNgrams($data, $n, $cyclic) as $item) {
42
8
yield $item;
43
}
44
}
45
46
12
return $ngrams;
47
}
48
49
/**
50
* @param $data
51
* @param $n
52
* @param $cyclic
53
*
54
* @return \Generator
55
*/
56
12
private function doNgrams($data, $n = 1, $cyclic = true)
Avoid variables with short names like $n. Configured minimum length is 3.
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.