chriso/klein.php — pull request #138 by Rican7 (2013-09-26 22:06:05+00:00)
Title: Feature - Code Restructuring

This PR fixes up a lot of awkward code that still existed; refactoring and restructuring pieces that needed a more modular structure for easier extension/customization.

Some of the duplicated argument parsing has been abstracted into a separate method, while the bulky `respond()` method has had its pieces abstracted into a new factory class (and abstract class) responsible for the somewhat complex logic used to process the entered paths as a regular expression, concerning namespaces and such.

This factory method is now dependency injected into the constructor of the Klein class, so that different factories can be implemented and used, allowing for a very flexible Route instance creation mechanism.

Also, new aliases for OPTIONS and HEAD requests have been created.

Finally, tests have been tweaked and added to comply with the new classes and abstractions.

This should cause no BC breaks, but will make the code more structured for a sexy 2.1 release. :smiley: