Main Classes Overview
Data Helpers provides five main classes for working with data:
DataAccessor
Section titled “DataAccessor”Read nested data with dot notation and wildcards. Analyze data structure with type information.
$accessor = new DataAccessor($data);
// Read values$email = $accessor->get('user.profile.email');$emails = $accessor->get('users.*.email');
// Get structure with type information$structure = $accessor->getStructure();// ['name' => 'string', 'emails.*' => '\EmailDTO', ...]DataMutator
Section titled “DataMutator”Modify nested data structures safely.
$mutator = new DataMutator($data);$mutator->set('user.name', 'John');$mutator->merge('user.settings', ['theme' => 'dark']);$mutator->unset('user.password');DataMapper
Section titled “DataMapper”Transform data structures with templates and pipelines.
$mapper = new DataMapper();$result = $mapper->map($source, [ 'user_name' => '{{ profile.name }}', 'user_email' => '{{ profile.email }}',]);DataFilter
Section titled “DataFilter”Query and filter data with SQL-like API.
$filter = new DataFilter($data);$result = $filter ->where('category', 'Electronics') ->where('price', '>', 100) ->orderBy('price', 'DESC') ->limit(10) ->get();SimpleDTO
Section titled “SimpleDTO”Immutable Data Transfer Objects with validation and casting.
class UserDTO extends SimpleDTO{ public string $name;
#[Email] public string $email;
#[Min(18)] public int $age;}
$user = UserDTO::from(['name' => 'John', 'email' => 'john@example.com', 'age' => 25]);