This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
63
{
64
$out = [];
65
foreach ($input as $line) {
66
$chunk = $this->chunk($line);
67
$out[] = reset($chunk);
68
}
69
return $out;
70
}
71
72
/**
73
* @param string $line
74
*
75
* @return string[]
76
*/
77
private function chunk($line)
78
{
79
if (mb_strlen($line) <= $this->width) {
80
return [$line];
81
}
82
$stripped = strip_tags($line);
83
$offset = 0;
84
$out = [];
85
86
// create a stripped tags version of the string
87
// loop through both and only move the counter if both characters are equal
88
// yield when we get to <width> for the stripped tags version
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.