This library has been deprecated and the repository archived. The functionality has been moved to the somnambulist/domain package.
Provides some useful interfaces and traits that can be used with entities. The traits implement on basic methods, and still require e.g. publish/unpublish to be implemented.
- PHP 7+
Install using composer, or checkout / pull the files from github.com.
- composer require somnambulist/entity-behaviours
Unlike the somnambulist/laravel-doctrine-behaviours package, these behaviours are intended to be used in a much more controlled and DDD based system. As such they do not implement setters and in some cases even the methods defined in the interfaces as these are core domain methods that should raise events within your system.
deactivate()methods to an entity controlling if it is active or not. The entity should implement activate/deactivate methods so that Events can be raised.
A collection of other interfaces: Identifiable, Nameable, Timestampable, UniversallyIdentifiable.
id()method that returns the primary identifier (int, string, object)
A combination of Identifiable and Timestampable
name()method that returns the entity name component.
ordinal()and update method for adding a numerical sorting index to an entity.
unpublish()for controlling if an Entity is "published". Uses the DateTime value object. publish/unpublish are not implemented as they should raise events when used.
toString()method that will use try the following methods:
If none are present an empty string is returned.
updatedAt()methods. Not setters are not defined as the entity should update the updatedAt when it is changed through update calls and not rely on database behaviour.
A collection of other interfaces: Identifiable, Nameable, Timestampable
uuid()method that returns a Uuid value object.
incrementVersion()methods for defining the current entity version. incrementVersion should be hooked in appropriate update methods when the entity is modified.
Helper class for accessing property methods/properties. Intended to be used in unit tests only.