for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Stratadox\Hydrator;
use Throwable;
/**
* Hydrates an object by calling its constructor with squashed array input.
*
* @package Stratadox\Hydrate
* @author Stratadox
*/
final class VariadicConstructor implements Hydrates
{
private $class;
private function __construct(string $forTheClass)
$this->class = $forTheClass;
}
* Creates a new variadic constructor calling hydrator.
* @param string $class The class to hydrate.
* @return Hydrates The variadic construction calling hydrator.
public static function forThe(string $class): Hydrates
return new self($class);
/** @inheritdoc */
public function fromArray(array $input)
$class = $this->class;
try {
return new $class(...$input);
} catch (Throwable $exception) {
throw HydrationFailed::encountered($exception, $class);
public function classFor(array $input): string
return $this->class;