Skip to content

Main Classes Overview

Data Helpers provides several 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');
// Type-safe collection getters
$ages = $accessor->getIntCollection('users.*.age'); // DataCollection<int>
// Get structure with type information
$structure = $accessor->getStructure();
// ['name' => 'string', 'emails.*' => '\EmailDto', ...]

Learn more →

Framework-independent type-safe collection class with fluent API for working with arrays.

$collection = DataCollection::make([1, 2, 3, 4, 5]);
// Filter, map, reduce with method chaining
$result = $collection
->filter(fn($item) => $item > 2)
->map(fn($item) => $item * 2)
->toArray(); // [6, 8, 10]
// Lazy evaluation for large datasets
foreach ($collection->lazyFilter(fn($item) => $item > 2) as $item) {
// Process items one at a time
}

Learn more →

Modify nested data structures safely.

$data = ['user' => ['name' => 'Jane']];
DataMutator::make($data)
->set('user.name', 'John')
->merge('user.settings', ['theme' => 'dark'])
->unset('user.password');
// $data is now modified in-place

Learn more →

Transform data structures with templates and pipelines.

$source = ['profile' => ['name' => 'John', 'email' => 'john@example.com']];
$result = DataMapper::source($source)
->template([
'user_name' => 'profile.name',
'user_email' => 'profile.email',
])
->map();

Learn more →

Query and filter data with SQL-like API.

$data = [
['category' => 'Electronics', 'price' => 150],
['category' => 'Electronics', 'price' => 50],
['category' => 'Books', 'price' => 200],
];
$result = DataFilter::query($data)
->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 →