public function setConfiguration($configuration = [])
{
if (is_array($configuration)) {
// Construct a configuration instance if an array is given.
$configuration = new DomainConfiguration($configuration);
} elseif (!$configuration instanceof DomainConfiguration) {
$class = DomainConfiguration::class;
throw new InvalidArgumentException("Configuration must be either an array or instance of {$class}");
}
$this->configuration = $configuration;
return $this;
}