Skip to content

Commit

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

return false;
}

/**
* @param $newPosition
* @param $position
* @param $tokenLength
*
* @return bool
*/
private function isPositionIn($newPosition, $position, $tokenLength)
{
return $newPosition >= $position && $newPosition < $position + $tokenLength;
}
}

0 comments on commit 3af3212

Please sign in to comment.