Download the PHP package danbettles/morf without Composer
On this page you can find all versions of the php package danbettles/morf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download danbettles/morf
More information about danbettles/morf
Files in danbettles/morf
Package morf
Short Description Morf is used to filter request-parameters *en masse*. It is configured with an array of definitions that describe each parameter you're interested in, and serves-up valid, type-cast values; it'll spit-out an exception when something's overtly wrong.
License ISC
Informations about the package morf
Morf
Morf is used to filter request-parameters en masse. It is configured with an array of definitions that describes each parameter you're interested in, and serves-up valid, type-cast values; it'll spit-out an exception when something's overtly wrong.
For safety's sake, Morf is strict and opinionated, and uses PHP built-ins whenever possible.
Example
It's pretty straightforward, as this example should—hopefully—show:
Valid Inputs
Type | Valid Input |
---|---|
bool , boolean |
"1" , "0" [^1] |
int , integer |
Any integer in string form |
float , double |
Any float/integer in string form |
string |
Any string :smile: |
array |
Any array |
[^1]: We take the view that being explicit is better (safer) in the long run. So, for example, a Boolean parameter with a blank value is treated as invalid because you can easily represent a Boolean value using "1"
or "0"
—which we think is more intuitive in any case.
Default Values
The built-in default values for each output-type—the values returned when parameters aren't set—are the same as those used in Symfony\Component\HttpFoundation\ParameterBag
, which we think are intuitive. No problem if you disagree, or if your application requires something different, because you can specify parameter-level default values—see the example above.