Skip to content

Commit

Permalink
Simplify the function
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed Jul 17, 2017
1 parent c607562 commit 531e59d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Botonomous/utility/MessageUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,21 @@ private function isPositionTaken(array $tokensPositions, $newPosition)
foreach ($tokensPositions as $token => $positions) {
$tokenLength = strlen($token);
foreach ($positions as $position) {
if ($newPosition >= $position && $newPosition < $position + $tokenLength) {
if ($this->isPositionIn($newPosition, $position, $tokenLength) === true) {
return true;
}
}
}

return false;
}

private function isPositionIn($newPosition, $position, $tokenLength)
{
if ($newPosition >= $position && $newPosition < $position + $tokenLength) {
return true;
}

return false;
}
}

0 comments on commit 531e59d

Please sign in to comment.