Skip to content

Commit

Permalink
Merge pull request #77 from pagarme/feature/PAOP-434-implement-change…
Browse files Browse the repository at this point in the history
…s-to-recurrence-order-description

🐛 added string verification at product helper
  • Loading branch information
M3ndes authored Jan 25, 2022
2 parents f5a0d4c + 85e35df commit e470bde
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Helper/ProductHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function getDiscountAmount($product)
*/
public static function extractValueFromTitle($title)
{
return (float)preg_replace('/[^0-9,]/', '', $title);
return (float)preg_replace('/[^0-9,]/', '', ProductHelper::getStringBetween($title, '(', ')'));
}

/**
Expand All @@ -104,6 +104,22 @@ public static function convertDecimalMoney($amount)
return $amount;
}

/**
* @param string $str
* @param string $starting_word
* @param string $ending_word
* @return string
*/
public static function getStringBetween($str, $first_string, $second_string)
{
$arr = explode($first_string, $str);
if (isset($arr[1])) {
$arr = explode($second_string, $arr[1]);
return $arr[0];
}
return '';
}

/**
* @param int $number
* @return float
Expand Down

0 comments on commit e470bde

Please sign in to comment.