Skip to content

Commit

Permalink
reduce lines
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed Jul 18, 2017
1 parent 75849f8 commit 4404fd0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Botonomous/utility/StringUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ public function findInString($toFind, $subject, $wordBoundary = true)
public function findPositionInString($toFind, $subject, $wordBoundary = true)
{
$pattern = $wordBoundary === true ? "/\b{$toFind}\b/" : "/{$toFind}/";
$result = preg_match_all($pattern, $subject, $matches, PREG_OFFSET_CAPTURE);

$positions = [];
if ($result && !empty($matches[0])) {
if (preg_match_all($pattern, $subject, $matches, PREG_OFFSET_CAPTURE) && !empty($matches[0])) {
foreach ($matches[0] as $match) {
$positions[] = $match[1];
}
Expand Down

0 comments on commit 4404fd0

Please sign in to comment.