
The reason I didn't do this is because I wanted to implement the given interface precisely. In my view, it would be better if the generate method was a static function as there is no real need to instantiate the class. To run the tests the following command "vendor/bin/phpunit tests" can be run.
#Roman numeral text generator install#
Finally I tidied everything up, added missing DocBlocks comments, and ensured indentation, code formatting, and line-endings, etc were all correct.įor testing I used PHPUnit, which is available for install using Composer and the "composer install" command (the composer.json file has been set up).I then was curious to see how much more efficient the new way was to the old way, so I wrote a crude benchmark to compare.During this time I had a eureka moment and found a different way to solve the problem, and in doing so drastically simplified the logic. Next, I tried to refactor and optimize the code, whilst still passing the test.Eventually, I passed the test, and as I understood the problem deeper, I updated my test to ensure I was testing all "kinds" of inputs.I then began to code with the goal of trying to pass the test, even if the code is a bit messy and/or inefficient.Next, I wrote what I believed to be an extensive test.I then began to set up my project folders and files, and built an environment upon which to write the code in.Next, I listed out many roman numerals in sequence within my text editor and tried to see if I could spot any patterns.First I learnt all that I could about roman numerals and how they work.Whilst working on this project, I documented the steps that I took in order to complete it. Next, you should run "composer install" to install all of the dependencies (mainly PHPUnit).įinally, you may execute the example.php file in your terminal or browser.

#Roman numeral text generator how to#
You will need PHP, Composer, and a bash terminal installed on your computer, with basic knowledge of how to use these technologies. I've included both to show my thinking and to demonstrate the coding knowledge I have.

I've included two implementations of the RomanNumeralGeneratorInterface, they both work however the first one is the one I would use in production as it is more efficient, the second was what I originally developed before I discovered a better way to solve the problem. The following class can be used to convert integers ranging from 1 – 3999 to roman numerals (e.g.
