Skip to content

Commit

Permalink
Improve function rank
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed Jul 18, 2017
1 parent c6a9871 commit 34f4745
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Botonomous/utility/MessageUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ private function isPositionTaken(array $tokensPositions, $newPosition)

foreach ($tokensPositions as $token => $positions) {
$tokenLength = strlen($token);
foreach ($positions as $position) {
if ($this->isPositionIn($newPosition, $position, $tokenLength) === true) {
return true;
}
if ($this->isPositionIn($newPosition, $positions, $tokenLength) === true) {
return true;
}
}

Expand All @@ -196,13 +194,19 @@ private function isPositionTaken(array $tokensPositions, $newPosition)

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

return false;
}
}

0 comments on commit 34f4745

Please sign in to comment.