-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactoring php v2 adam #4
base: main
Are you sure you want to change the base?
Conversation
'Purchase of {amount} with {card} at {brand},', | ||
'Payment of {amount} to {brand} with {card}.', | ||
]; | ||
private $keywords = ['amount', 'brand', 'card', 'account', 'datetime']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this array? can we simply replace anything with the {} with "(.*?)"
|
||
class SmsTemplateDetector | ||
{ | ||
private $templates = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good move. however, do you think this data should be in this class?
foreach($this->templates as $template) { | ||
$re_pattern = $this->getRePattern($template); | ||
|
||
if(preg_match($re_pattern, $sms, $matched_parts)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we simplify this condition as a method to make it more readable?
test('it returns correct matched template with extracted data', function () { | ||
$sut = new SmsTemplateDetector; | ||
|
||
$smsTemplate = $sut->detect("Payment of 33.3 to Apple with 4233."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add the missing tests and convert this into dataset testing
what do you think ?