This this implementation of RPN Calculator by php.
I hope you have installed required php.
So run composer install that's all.
php ./console calc
php ./vendor/bin/phpunit ./tests/
-
You should implement
OperatorInterface, path:src/Contract/OperatorInterface.php, see comments for get details requirements of implementation. -
And add this implementation to
.\services.ymlwith tagtag.operator
App\Operators\PlusOperator:
class: App\Operators\PlusOperator
tags: [app.operator]
I try not break SOLID principles. So I don't create dependency not on realization in 95% codes of this application.
I make builder for calculator values stack, for the same reason and because I assume this functionality can be implemented on other side of the system, for example on frontend side and with database using.
You can replace implementation for other part of current application too.
You should only re-implementing some contract, make test for it (and use current test cases) and change bind for this abstraction in .\services.yml
-
I don't realized tests for all classes. I hope current test cases, should be enough for understand my skill.
-
I really don't sure in
ValueValidatorclass, maybe it should be responsibility of OneStepCalculator, but this thing don't like me too. -
I understand that injected operators to operators collection should be in loading by settings in services.yml, but I can't fast find a solution how do it.