dhii / data-object-abstract
Abstract common functionality for data objects
Installs: 3 190
Dependents: 7
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 1
Requires
- php: ^5.4 | ^7.0
Requires (Dev)
- codeclimate/php-test-reporter: <=0.3.2
- dhii/php-cs-fixer-config: ^0.1
- dhii/stringable-interface: ^0.1
- phpunit/phpunit: ^4.8
- psr/container: ^1.0
- ptrofimov/xpmock: ^1.1
Suggests
- dhii/exception-helper-base: For standard exception factories
- dhii/stringable-interface: To be able to pass stringable objects as keys and messages
This package is auto-updated.
Last update: 2024-12-07 03:46:27 UTC
README
Details
This package contains abstract functionality for data objects. Data objects are objects that can contain, and optionally
manipulate, some internal data. The implementations in this package are based on containers, which means that anything
returned by _normalizeContainer
can have a data object based
on it. Another advantage of this implementation is that a data key can be anything that passes normalization by
normalizeString()
. All this makes this package an excellent base
for flexible, extensible data objects.
Important Notice: While the traits that access the internal store can work with any container, the _getDataStore()
method used by them MUST return an object for the methods that write to the store to have an effect. This is to avoid
having to use references, which would complicate the code and make it more error-prone, and less optimized.
Traits
GetDataCapableTrait
- Retrieves data by key from the internal store.SetDataCapableTrait
- Sets a data value by key in the internal store.SetManyCapableTrait
- Sets multiple data values by key-value map in the internal store.HasDataCapableTrait
- Establishes whether a key exists in the internal store.UnsetDataCapableTrait
- Removes data by key from the internal store.UnsetManyCapableTrait
- Removes multiple values by key list from the internal store.DataStoreAwareContainerTrait
- Retrieves the internal store.CreateDataStoreCapableTrait
- Creates an object that can serve as an internal store.NormalizeKeyCapableTrait
- Makes sure that a data key can be used to retrieve a value from the internal store.