for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Doctrine\SkeletonMapper\Hydrator;
use Doctrine\SkeletonMapper\ObjectManagerInterface;
use InvalidArgumentException;
use function get_class;
use function sprintf;
/**
* Basic object hydrator that delegates hydration
* to a method on the object that is being hydrated
* or uses a dynamic hydration algorithm.
*/
class BasicObjectHydrator extends ObjectHydrator
{
/** @var ObjectManagerInterface */
protected $objectManager;
public function __construct(ObjectManagerInterface $objectManager)
$this->objectManager = $objectManager;
}
* @param object $object
* @param mixed[] $data
public function hydrate($object, array $data) : void
if (! $object instanceof HydratableInterface) {
throw new InvalidArgumentException(sprintf(
'Class %s does not implement %s.',
get_class($object),
HydratableInterface::class
));
$object->hydrate($data, $this->objectManager);