Download the PHP package mistralys/application-utils-collections without Composer
On this page you can find all versions of the php package mistralys/application-utils-collections. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mistralys/application-utils-collections
More information about mistralys/application-utils-collections
Files in mistralys/application-utils-collections
Package application-utils-collections
Short Description Interfaces, traits and classes for handling static item collections, similar to Enums and with useful getter methods.
License MIT
Informations about the package application-utils-collections
AppUtils - Collections
Interfaces, traits and classes for handling static item collections, similar to Enums and with useful getter methods.
In essence, it allows creating collections like this with a minimum of code:
This is part of the Application Utils ecology.
The Principle
The basic principle is to have a collection class for a data type, which knows all the possible values for that type, and a record class that represents a single value of that type.
The collections and records are distinguished by the return type of
their getID()
method.
Currently, only string and integer types are supported.
Implementation
There are two ways to implement collections:
- By extending the abstract base classes (e.g.
BaseStringPrimaryCollection
) - By implementing the interface and trait (e.g.
StringPrimaryCollectionTrait
)
The second way is useful when working with classes that already extend another class.
The records have no abstract base class, only an interface that
contains the getID()
method with the relevant return type.
Usage
There are example implementations of the string and integer collections in the unit test classes:
- Integer collection
- Integer record
- String collection
- String record
- String collection, with class folder loading