for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Infrastructure\Utility;
final class Hydrator
{
/**
* Hydrate a collection of objects with data from an array items.
*
* @template T
* @param array<array<string, mixed>> $rows The items
* @param class-string<T> $class The FQN
class-string<T>
0
* @return T[] The list of object
*/
public function hydrate(array $rows, string $class): array
$result = [];
foreach ($rows as $row) {
// Some classes like UserData have a restriction
$result[] = new $class($row, true);
}
return $result;