restructr
domain component foundation
Installation
Install via cli using composer:
php composer.phar require jgswift/restructr:0.1.*
Install via composer.json using composer:
{
"require": {
"jgswift/restructr": "0.1.*"
}
}
Dependency
- php 5.5+
Description
restructr provides a set of foundational component abstractions in order to facilitate domain driven development in PHP. With no exception, the component foundation classes are composed at compile-time by traits, allowing a flexible approach that requires little imposition on an already existing domain model. restructr provides these domain driven abstractions from both array-first or object-first perspectives. restructr assumes very little about any given domains implementation and allows significant customization of existing functionality.
Component Abstractions
Entity
- A single identifiable componentCollection
- A collection ofEntity
componentsValueArray
- An immutableArrayAccess
(offsetGet
,offsetSet
, etc..)ValueObject
- An immutableObjectAccess
(__get
,__set
, etc..)CollectionEntity
- AnEntity
component that also accepts/serializes an innerCollection
CollectionIterator
- ACollection
of non-accessable but iterableEntity
components.EntityIterator
- AEntity
of non-accessable but iterable domain data
As mentioned above, it is possible to include these concepts into an already existing domain without extending the provided abstractions. Nearly all abstractions are provided as composable traits that may be used or combined in any number of ways.
Trait Extensions
These traits are included to customize domain implementations in various ways. Some of these are foundational to the provided component abstractions, while others may be excluded or included on a per-domain basis.
ArrayAccess
- SPLArrayAccess
implementation using local domain dataArrayAggregate
- SPLIteratorAggregate
implementation using local domain dataArrayAttributable
-ArrayAccess
key restraints as defined bygetAttributes
methodArrayEnumerable
-Enumerable
implementation to retrieve local domain dataArrayEnumerableAggregate
- SPLIterateAggregate
implementation usingEnumerable
dataArrayImmutable
-ArrayAccess
implementation that disallows mutation (offsetSet
,offsetUnset
)ArrayIterator
- SPLIterator
implementation using local domain dataCountable
- SPLCountable
implementation using local domain dataObjectAccess
- Object magic implementation based onArrayAccess
traitObjectAttributable
-ObjectAccess
property restraints as defined bygetAttributes
methodObjectEnumerable
-ArrayEnumerable
aliasObjectImmutable
-ObjectAccess
implementation that disallows property mutation (__set
,__unset
)RecursiveArrayIterator
- SPLRecursiveIterator
implementation that uses RecursiveArrayIterator from SPLRecursiveIterator
- Minimal SPLRecursiveIterator
implementationRecursiveSerializer
-Enumerable
implementation that recursively converts domain data to an array