Skip to content

Main Classes Overview

Data Helpers provides five main classes for working with data:

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', ...]

Learn more →

Modify nested data structures safely.

$mutator = new DataMutator($data);
$mutator->set('user.name', 'John');
$mutator->merge('user.settings', ['theme' => 'dark']);
$mutator->unset('user.password');

Learn more →

Transform data structures with templates and pipelines.

$mapper = new DataMapper();
$result = $mapper->map($source, [
'user_name' => '{{ profile.name }}',
'user_email' => '{{ profile.email }}',
]);

Learn more →

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();

Learn more →

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]);

Learn more →