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
JDZ Data
A PHP utility class for manipulating nested arrays using dot notation.
Features
- 🎯 Dot Notation: Access nested array values with simple dot notation (
user.profile.name) - 🔢 Numeric Keys: Work seamlessly with array indices
- 🔄 Bulk Operations: Set multiple values at once with merge support
- 🎨 Typed Getters: Type-safe retrieval with
getBool(),getInt(),getArray() - 🔗 Method Chaining: Fluent interface for elegant code
- 🎭 Null Handling: Optional null value preservation
- ✅ Type Safe: Full PHP 8.0+ type declarations
Installation
Requirements
- PHP 8.0 or higher
Quick Start
Documentation
Setting Values
set(string $path, mixed $value): self
Set a single value using dot notation.
sets(array $data, bool $merge = true): self
Set multiple values at once.
Getting Values
get(string $path, mixed $default = null): mixed
Get a value with an optional default.
getBool(string $path, bool $default = false): bool
Get a boolean value. Converts 1, '1', and true to true.
getInt(string $path, int $default = 0): int
Get an integer value with automatic type conversion.
getArray(string $path, array $default = []): array
Get an array value. Non-array values are cast to arrays.
Checking and Removing
has(string $path): bool
Check if a key exists.
erase(string $path): self
Remove a value.
def(string $path, mixed $default = ''): self
Set a value only if it doesn't already exist.
Utility Methods
all(): array
Get all data as an array.
preserveNulls(bool $preserve = true): self
Enable or disable null value preservation.
Working with Arrays
Access array elements using numeric keys:
Build complex structures:
Method Chaining
All mutating methods return $this for fluent chaining:
Examples
See the examples directory for detailed examples:
01-basic-usage.php- Basic operations02-typed-getters.php- Typed getter methods03-array-keys.php- Working with arrays04-bulk-operations.php- Bulk setting operations05-erase-and-def.php- Removing and defaulting values06-null-handling.php- Null value handling07-method-chaining.php- Method chaining examples
Run example:
Testing
Run all tests:
Run tests with coverage report (HTML):
License
This project is licensed under the MIT License - see the LICENSE file for details.