Download the PHP package mascame/katina without Composer
On this page you can find all versions of the php package mascame/katina. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mascame/katina
More information about mascame/katina
Files in mascame/katina
Package katina
Short Description Test helper class that validates any kind of output based on the rules passed. Useful to test API reponses or data that changes over time.
License MIT
Informations about the package katina
Katina - The PHP Output Validator
Test helper class that validates any kind of output based on the passed rules. Useful to test API reponses or data that changes over time.
A modernized version of ptrofimov/matchmaker package.
Installation
composer require mascame/katina --dev
Basic usage
Advanced usage
Adding rules
Matching rules
Matching rules are strings that start with ':'. You can use multiple matchers joined with space.
Matcher could be any callable (name of function or closure). You can add your own rules or replace standard ones.
-
General
- empty
- nonempty
- required
- in(a, b, ...)
- mixed
- any
-
Types
- array
- bool
- boolean
- callable
- double
- float
- int
- integer
- long
- numeric
- number
- object
- real
- resource
- scalar
- string
-
Numbers
- gt(n)
- gte(n)
- lt(n)
- lte(n)
- negative
- positive
- between(a, b)
-
Strings
- alnum
- alpha
- cntrl
- digit
- graph
- lower
- punct
- space
- upper
- xdigit
- regexp(pattern)
- url
- ip
- length(n)
- min(n)
- max(n)
- contains(needle)
- starts(s)
- ends(s)
- json
- date
-
Arrays
- count(n)
- keys(key1, key2, ...)
-
Objects
- instance(class)
- property(name, value)
- method(name, value)
For more details click here
Quantifiers for keys
- ! - one key required (default)
- ? - optional key
-
-
- any count of keys
-
- {3} - strict count of keys
- {1,5} - range
For matchers (i.e. ':string') default quantifier is *
Using Matcher as standalone
You can directly use Matcher:
Contributing
Thank you for considering contributing! You can contribute at any time forking the project and making a pull request.
Support
If you need help or any kind of support, please send an e-mail to Marc Mascarell at [email protected].
License
Credit to Petr Trofimov for his package ptrofimov/matchmaker which this package is heavily based on.
MIT