Download the PHP package jgswift/qtil without Composer
On this page you can find all versions of the php package jgswift/qtil. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package qtil
qtil
PHP 5.5+ utility library
Description
This package contains a variety of utilities to assist in development and reduce boilerplate.
Installation
Install via cli using composer:
Install via composer.json using composer:
Dependency
- php 5.5+
- jgswift/restructr domain component foundation
Usage
ArrayAccess
The following is an ArrayAccess minimal example
ObjectAccess
Much like ArrayAccess, ObjectAccess is available for conventional object magic..
While the following example appears to be default object behavior, all accessors and mutators are handled through magic and properties are stored locally in an array
JSONAccess
The JSONAccess trait provides integrated JSON serialization and may be applied to both ObjectAccess and ArrayAccess objects.
Serializable
Normal object serialization is also available using the Serializable interface/trait combination. Regular serialization is also available to both ArrayAccess and ObjectAccess.
Iterator
Qtil provides standard Iterator and IteratorAggregate implementations through the traits names Iterator and IteratorAggregate respectively.
IteratorAggregate
IteratorAggregate Custom Iterator
The iterator aggregate trait provides a convenience property to specify the iterator manually. By default, ArrayIterator is used.
Generator
A generator function may be specified to easily customize the iteration process without requiring a custom .
Identifier
Qtil contains a small utility to easily customize how objects are identified.
There are some default schemes for identifying objects that ensures individual object instances are identified respectively. You can use this functionality instead of spl_object_hash to ensure identifier uniqueness. Alternatively, a number of built-in schemes are available.
The following is the minimal example, using the default scheme
With a minor change, you can encapsulate the identification behavior in your own class
Schemes
Alternatively, qtil provides a number of built-in schemes using a variety of ways to determine how to identify an object.
You may provide a custom callback method for most schemes
Factory
Object creation done by Reflection and arguments validated against constructor signature
A qtil\Exception is thrown is the given arguments do not match the class constructor
Proxy
A simple magic mediator.
Mediates an object instance through locally-scoped magic methods, namely get, set, unset, isset, and __call
Executable (Command)
This simple trait makes an object a callable and exposes the call through the execute method. The execute method may have any arguments and does not enforce any particular method signature.
Method Chaining
The chaining mechanism outlined below favors convention over configuration. Chainable methods are populated by all of the classes that are direct children of one or more namespaces. The namespaces are customizable but the default is a single namespace that matches the class signature of the chained class
Note: any traits that use magic methods such as get, set, etc. are not compatible with eachother unless you provide a custom implementation to manually route duplicate methods. See the php traits documentation, specifically the insteadof operator.