config = $config; $this->inflector = $inflector ?: Inflector::getDefault(); } /** * {@inheritdoc} */ public function build($waiter) { return new ConfigResourceWaiter($this->getWaiterConfig($waiter)); } /** * {@inheritdoc} */ public function canBuild($waiter) { return isset($this->config[$waiter]) || isset($this->config[$this->inflector->camel($waiter)]); } /** * Get waiter configuration data, taking __default__ and extensions into account * * @param string $name Waiter name * * @return WaiterConfig * @throws InvalidArgumentException */ protected function getWaiterConfig($name) { if (!$this->canBuild($name)) { throw new InvalidArgumentException('No waiter found matching "' . $name . '"'); } // inflect the name if needed $name = isset($this->config[$name]) ? $name : $this->inflector->camel($name); $waiter = new WaiterConfig($this->config[$name]); $waiter['name'] = $name; // Always use __default__ as the basis if it's set if (isset($this->config['__default__'])) { $parentWaiter = new WaiterConfig($this->config['__default__']); $waiter = $parentWaiter->overwriteWith($waiter); } // Allow for configuration extensions if (isset($this->config[$name]['extends'])) { $waiter = $this->getWaiterConfig($this->config[$name]['extends'])->overwriteWith($waiter); } return $waiter; } }