Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed Jul 17, 2017
1 parent 18b0670 commit 61ba31d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Botonomous/utility/MessageUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ public function keywordPos(array $keywords, $message)
return $found;
}

usort($keywords, function($array1, $array2) {
return strlen($array2) <=> strlen($array1);
});
usort($keywords, [$this, 'compareLength']);

foreach ($keywords as $keyword) {
$result = preg_match_all("/\b{$keyword}\b/", $message, $matches, PREG_OFFSET_CAPTURE);
Expand All @@ -153,6 +151,11 @@ public function keywordPos(array $keywords, $message)
return $found;
}

private function compareLength($array1, $array2)
{
return strlen($array2) <=> strlen($array1);
}

private function isPositionTaken(array $tokensPositions, $newPosition)
{
if (empty($tokensPositions)) {
Expand Down

0 comments on commit 61ba31d

Please sign in to comment.