Conversation
|
@money-team let me know if this going to the correct direction for you in order to finalize the PR and fix the CI failures. |
|
@gmponos Why not inject a Decimal parser and then delegate the parsing process once you have handled the exponential part? Maybe I should have a closer look, but as it seems to me there is a lot of duplicate code? public function __construct(Currencies $currencies, DecimalMoneyParser $delegatedParser) {
$this->currencies = $currencies;
$this->delegatedParser = $delegatedParser;
}
public function parse($money, $forceCurrency = null) {
// ....
$number = number_format($expo, $subunit, '.', '');
return $this->delegatedParser->parse($number, $forceCurrency);
} |
|
@frederikbosch I though about the same solution too. But I dislike it for the following reasons:
ExponentialParser.php The same checks above will be checked again inside the
Anyway my current solution stands to the following facts:
|
|
A trait indeed seems to be an easier solution in this case as the delegated parser would always be a decimal parser. |
sagikazarmark
left a comment
There was a problem hiding this comment.
Looks good to me! Should wait for the trait though
Co-Authored-By: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com>
|
|
||
| if (null === $forceCurrency) { | ||
| throw new ParserException( | ||
| 'DecimalMoneyParser cannot parse currency symbols. Use forceCurrency argument' |
There was a problem hiding this comment.
Shouldn't this say "ExponentialMoneyParser", not "DecimalMoneyParser"?
|
@gmponos Could you update this PR against the latest master? Sorry for our very late action on this. |
|
Superseded by #668. |
Created a new Parser that will be able to parse exponential values to Money object. This solves the issue that I have presented on this PR #494
This parser is used only for exponential values and not for decimals.. It will be good to be used combined with an Aggregator parser and a decimal parser.