diff --git a/.circleci/config.yml b/.circleci/config.yml index 8d6c7b2b..6a8e5986 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,5 +71,5 @@ workflows: name: build-php-<< matrix.php_version >> matrix: parameters: - php_version: ["8.0", "8.1", "8.2"] + php_version: ["8.0", "8.1", "8.2", "8.3"] xdebug_version: ["stable"] diff --git a/src/Language/German/GermanDictionary.php b/src/Language/German/GermanDictionary.php index c790a6aa..61c7a673 100644 --- a/src/Language/German/GermanDictionary.php +++ b/src/Language/German/GermanDictionary.php @@ -124,7 +124,7 @@ class GermanDictionary implements Dictionary public function getMinus(): string { - return 'Minus'; + return 'minus'; } public function getZero(): string diff --git a/src/NumberTransformer/GenericNumberTransformer.php b/src/NumberTransformer/GenericNumberTransformer.php index 7c6ba24b..44d0ea0a 100644 --- a/src/NumberTransformer/GenericNumberTransformer.php +++ b/src/NumberTransformer/GenericNumberTransformer.php @@ -27,9 +27,10 @@ public function toWords(int $number): string } $words = []; + $minus = ''; if ($number < 0) { - $words[] = $this->dictionary->getMinus(); + $minus = $this->dictionary->getMinus(); $number *= -1; } @@ -37,7 +38,7 @@ public function toWords(int $number): string $words = array_merge($words, $this->getWordsBySplittingIntoTriplets($number)); } - return trim(implode($this->wordsSeparator, $words)); + return trim(sprintf('%s %s', $minus, implode($this->wordsSeparator, $words))); } private function getWordsBySplittingIntoTriplets(int $number): array diff --git a/tests/NumberTransformer/GermanNumberTransformerTest.php b/tests/NumberTransformer/GermanNumberTransformerTest.php index 20d11c5a..8b7eea62 100644 --- a/tests/NumberTransformer/GermanNumberTransformerTest.php +++ b/tests/NumberTransformer/GermanNumberTransformerTest.php @@ -12,6 +12,8 @@ protected function setUp(): void public function providerItConvertsNumbersToWords(): array { return [ + [-287, 'minus zweihundertsiebenundachtzig'], + [-10, 'minus zehn'], [0, 'null'], [1, 'eins'], [2, 'zwei'],