Skip to content

bairwell/emojicalc

Repository files navigation

This is an "EmojiCalculator" written by Richard Bairwell of Bairwell Ltd.

Composer is only used in development environment for unit testing using PHPUnit 6.

At the time of writing, the code is 100% unit tested.

What is it?

This is a proof of concept/PHP technical test I took part in in the space of 4 hours in January 2017. The test involved writing a "simple web based emoji calculator" (where the operators were emoji characters). During this time, I built the entire application framework (using inspiration from my work on Slim3 projects), built the frontend and JSON interfaces (the system does use jQuery and Bootstrap, but this is the only 3rd party code) and had a fully functional system at the end of the four hour period.

Apart from jQuery/Bootstrap, all the remaining code is fully written by myself (okay, index.php isn't, and PHPStorm autogenerated some of the comments and implementor method outlines - but the "functional" code is all mine).

Since then, I've spent some time tidying up the code (bringing it up to my "own" standards), interfacing a number of classes and unit testing everything (writing the unit tests took the longest time).

Feel free to give it a spin!

Requirements

Tested on PHP 7.1.

Design patterns used

Abstract factory - Used for the Entities/Operator.

Lazy Initialization - Used in App.php under the container system.

Bridge - All major classes are designed to interface or abstracts.

Front controller - Used by index.php .

Iterator - Used in Operators.

State - Used in Router.

MVC - Used on the whole system.

There's probably quite a few other design patterns used depending on their classification.

Licence/License

(MIT)

Copyright (c) 2016 Bairwell Ltd/Richard Bairwell.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Vagrant based startup

The Vagrant install is based on the PHP7 dev box , but has been configured to shutdown the standard nginx webserver and startup the PHP inbuilt webserver on port 8000 and map that port to the host.

To start as a Vagrant image, just download and run:

vagrant up

Once the message

==> default: Ready - access http://localhost:8000/ to preview

appears, you can then access the files as http://localhost:8000/.

If you need to change the port number used, just up the Vagrantfile and change the listening_port and the start before running vagrant up.

Non-Vagrant startup

Just download the files onto your machine (which already has) and run a command such as:

php -S localhost:8000 emojicalc/public/index.php

to launch the PHP inbuilt web server on the localhost only on port 8000 and serve the files within the public/ folder.

You can then access the files as http://localhost:8000/

About

An Emoji Calculator as a proof of concept

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published