Download the PHP package zombietfk/thatcher without Composer
On this page you can find all versions of the php package zombietfk/thatcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zombietfk/thatcher
More information about zombietfk/thatcher
Files in zombietfk/thatcher
Package thatcher
Short Description A pattern matcher for arguments and arrays of data. Supports callbacks based on passed set
License
Informations about the package thatcher
Thatcher
A PHP pattern matcher for arguments and arrays of data
Thatcher matches data sets of data and based on that data runs a callback
I was inspired by functionality in other langauges like haskell and rust to make functionality availiable in a langauge like php, even if it's only something basic
Here is a short section with a quick example of a basic implementaion
In this case the function associated with Pattern('hello!', _,_) will be ran, as it is the first of the When clauses that matches in input from top to bottom.
Here are some examples of other patterns you could use
Calling the getParsedParameters method with invalid data will result in a NonMatchingInputException, so make sure that you call
the matches method first to check or handle it yourself Similarly, the same Exception will be raised in a Match clause
if the given data does not match any of it's patterns. It is usually good practice to include both a Pattern() and final Pattern([_]) in your matches.
Finally, there Classes as well, don't worry, the aliases are just basic functions (or consts) hiding the new'ing them up
Future Plans
-
Add
StringPatterntype which will treat strings as sets of characters, making matching them easier - Rename existing
Patterntype toSetPattern