Download the PHP package mymedia/php-argument-builder without Composer
On this page you can find all versions of the php package mymedia/php-argument-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mymedia/php-argument-builder
More information about mymedia/php-argument-builder
Files in mymedia/php-argument-builder
Package php-argument-builder
Short Description Abstract argument builder library
License MIT
Informations about the package php-argument-builder
Master |
---|
Argument Builder Library
AbstractArgumentBuilder class is used to build a query string from pre-defined validatable parameters. It can also be used to the reverse so that the application uses only the desired validated parameters. Generates its own property getters and setters and unset via automated magic function.
Installation
First, install the dependency:
Usage examples
Basic usage
AbstractArgumentBuilder
AbstractArgumentBuilder implements ArgumentBuilderInterface which provides only one method: build(). Magic function call() provides access to getters and setters, and unset, without the need to generate them manually. It also provides us with toString() function that returns http query string.
Using the provided functionality, the presented code will generate query arguments like: http://example.com/?search=foobar&filter[color]=iridescent&filter[size][height]=2&filter[size][width]=10.
However this requires additional classes to extend the AbstractArgumentBuilder
that we will define in the next section.
Extending AbstractArgumentBuilder
Argument Types
AbstractArgumentBuilder
defines following constants, that are used in field validation:
Classes
Field Validation
A simple way to provide field validation, it will fail if the defined condition is not met:
Code license
You are free to use the code in this repository under the terms of the MIT license. LICENSE contains a copy of this license.