Skip to content

Commit

Permalink
Fix number conversion issue in PersianConverterBuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaMoradi9571 committed Jan 13, 2025
1 parent 79af51f commit 8604cb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/PersianConverterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public function build(): PersianConverter
NumberType::ENGLISH,
NumberType::PERSIAN
);
} else {
$this->strategies[] = new NumberConversionStrategy(
NumberType::PERSIAN,
NumberType::ENGLISH
);
}
$this->strategies[] = new NumberConversionStrategy(
NumberType::ARABIC,
Expand Down
4 changes: 2 additions & 2 deletions tests/PersianConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public function testBuilderWithAllOptions(): void
->withNumberConversion(keepEnglishNumbers: true)
->build();

$input = 'Hello123 سلام٤٥٦ يك';
$expected = 'Hello123 سلام456 یک';
$input = 'Hello123 سلام ۷۸۹ ٤٥٦ يك';
$expected = 'Hello123 سلام 789 456 یک';
$this->assertEquals($expected, $converter->convert($input));
}

Expand Down

0 comments on commit 8604cb2

Please sign in to comment.