Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Nov 28, 2023
1 parent 201a334 commit cabde88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"doctrine/orm": "^2.8",
"jms/serializer": "^3.14",
"jms/serializer-bundle": "^3.8 || ^4.0 || ^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "1.10.34",
"phpstan/phpstan-phpunit": "1.3.14",
Expand Down
12 changes: 6 additions & 6 deletions src/Validator/Constraints/AbstractMoneyComparisonValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,21 @@ private function ensureMoneyObject(AbstractMoneyComparison $constraint, Money|fl
if (\is_string($value) && str_contains($value, '.')) {
try {
return $this->parserFactory->createParser($constraint->parserFormat, $constraint->locale, $this->createFactoryOptions($constraint))->parse($value, new Currency($constraint->currency ?: $this->defaultCurrency));
} catch (ParserException) {
throw new InvalidArgumentException(sprintf('Could not convert value "%s" to a "%s" instance for comparison.', $value, Money::class));
} catch (ParserException $exception) {
throw new InvalidArgumentException(sprintf('Could not convert value "%s" to a "%s" instance for comparison.', $value, Money::class), 0, $exception);
}
}

try {
$number = \is_float($value) ? Number::fromFloat($value) : Number::fromNumber($value);
} catch (\InvalidArgumentException) {
throw new InvalidArgumentException(sprintf('Could not convert value "%s" to a "%s" instance for comparison.', $value, Number::class));
} catch (\InvalidArgumentException $exception) {
throw new InvalidArgumentException(sprintf('Could not convert value "%s" to a "%s" instance for comparison.', $value, Number::class), 0, $exception);
}

try {
return new Money((string) $number, new Currency($constraint->currency ?: $this->defaultCurrency));
} catch (\InvalidArgumentException) {
throw new InvalidArgumentException(sprintf('Could not convert value "%s" to a "%s" instance for comparison.', $value, Money::class));
} catch (\InvalidArgumentException $exception) {
throw new InvalidArgumentException(sprintf('Could not convert value "%s" to a "%s" instance for comparison.', $value, Money::class), 0, $exception);
}
}

Expand Down

0 comments on commit cabde88

Please sign in to comment.