Download the PHP package new-inventor/data-structure without Composer
On this page you can find all versions of the php package new-inventor/data-structure. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download new-inventor/data-structure
More information about new-inventor/data-structure
Files in new-inventor/data-structure
Package data-structure
Short Description Data structure transformers and validators config
License MIT
Informations about the package data-structure
Property bag
This utility provide to you data structure metadata and some useful classes.
With this packet you can transform arrays to needed format and load it to objects recursive.
Objects to load MUST implement Loadable or DataStructureInterface interface.
Installation
composer require new-inventor/data-structure
Examples
Metadata config
Recursive loading
You can load properties recursive by using RecursiveConstructor.
To use this you shoul add nested
parameter to property like this
or
or
Namespace
It is the namespace for data structure class for recursive loading.
Validation
It is the symfony class validation config. You can pass it directly into property
Properties
It is properties of your data structure.
Property has this parameters:
- default
- transformers
- validation
- nested
If property === null(~) then default = null and no transformers and validators If property is string then default = null and default transformers = this string
transformers
Transformers is array of arrays.
In yml like this:
So you can set transformer like this:
By default transformer is inner transformer, but you can create you own and pass full class name to transformer config
Transformer can receive array or parameters and parameter can be array(1) with reserved word as key; Reserved words:
- static - interpret as static property of class
['class', 'propertyName']
- const - interpret as constant can be array like static or string
- groups - transformer groups, by default
groups = ['default']
.
If in transformers section more than 1 transformer in same group then this transformers will be wrapped by ChainTransformer, so this identical:
and
Validation
It is the getters part of symfony validation config for given property
Default
Default can be any value and have same reserved keys as transformer parameters, but group.
Nested
It is described in Recursive loading section.
PropertiesTransformer
or you can compose PropertiesTransformer by yourself
RecursiveConstructor
This constructor construct class with metadata by recursive loading it nested classes.
Links
- To use only transformers use https://github.com/new-inventor/transformers
- To implement property bags use https://github.com/new-inventor/property-bag
All versions of data-structure with dependencies
new-inventor/php-type-checker Version ^5.0
new-inventor/transformers Version ^1.0
symfony/validator Version ^3.3
symfony/cache Version ^3.3
symfony/yaml Version ^3.3
symfony/config Version ^3.3