Download the PHP package jdz/data without Composer
On this page you can find all versions of the php package jdz/data. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package data
Data
The Data
class is a utility for managing deeply nested associative arrays and objects. It allows for manipulation, traversal, and transformation of data using dot notation for keys. This is particularly useful for complex data structures where direct access or modification is cumbersome.
Features
- Dot Notation Access: Access, set, or delete deeply nested keys using a simple
dot.notation
syntax. - Flattening and Unflattening: Convert nested arrays to a flat structure with dot notation and vice versa.
- Type-Specific Retrieval: Fetch values as specific types such as
int
,bool
, orarray
. - Default Value Handling: Retrieve values with fallback defaults if the key does not exist.
- Merge and Overwrite: Merge new data into existing data with fine-grained control.
Installation
To include this class in your project, use composer:
Usage
Initialization
Setting Values
Getting Values
Checking for Existence
Flattening Data
Protected method, can be used in a derived class
Unflattening Data
Protected method, can be used in a derived class
Merging Data
Deleting Values
Methods
Public Methods
Method | Description |
---|---|
set() |
Sets a value at the specified path. |
get() |
Retrieves a value from the specified path, with an optional default. |
getBool() |
Retrieves a boolean value from the specified path. |
getInt() |
Retrieves an integer value from the specified path. |
getArray() |
Retrieves an array value from the specified path. |
def() |
Sets a default value if the key does not exist. |
has() |
Checks if a value exists at the specified path. |
erase() |
Deletes a value at the specified path. |
all() |
Returns all stored data. |
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
(c) Joffrey Demetz [email protected]