config = new ConfigMerge($config, $group, $prefix, $postfix); } public function apply($object, $configurationKey) { $settings = $this->config->get($configurationKey); foreach ($settings as $setterMethod => $args) { $fn = [$object, $setterMethod]; if (is_callable($fn)) { $result = call_user_func_array($fn, (array)$args); // We require that $fn must only be used with setter methods. // Setter methods are required to always return $this so that // they may be chained. We will therefore throw an exception // for any setter that returns something else. if ($result != $object) { $methodDescription = get_class($object) . "::$setterMethod"; $propertyDescription = $this->config->describe($configurationKey); throw new \Exception("$methodDescription did not return '\$this' when processing $propertyDescription."); } } } } }