Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

refactoring php v2 adam #4

wants to merge 1 commit into from

Conversation

Maen1
Copy link

@Maen1 Maen1 commented Aug 7, 2023

what do you think ?

'Purchase of {amount} with {card} at {brand},',
'Payment of {amount} to {brand} with {card}.',
];
private $keywords = ['amount', 'brand', 'card', 'account', 'datetime'];
Copy link
Owner

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 = [
Copy link
Owner

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)) {
Copy link
Owner

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.");
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants