config = $config; } /** * @param string $name The method name. * @param array $args Arguments that will be passed to the method. * * @return \DTS\eBaySDK\Services\BaseService * @throws \BadMethodCallException */ public function __call($name, array $args) { if (strpos($name, 'create') === 0) { return $this->createService( substr($name, 6), isset($args[0]) ? $args[0] : [] ); } throw new \BadMethodCallException("Unknown method: {$name}."); } /** * Create a service object by namespace. Service is configured using array of options. * * @param string $namespace Service namespace (e.g. Finding, Trading). * @param array $config Configuration options for the service. * * @return \DTS\eBaySDK\Services\BaseService **/ public function createService($namespace, array $config = []) { $configuration = $this->config; if (isset($this->config[$namespace])) { $configuration = arrayMergeDeep($configuration, $this->config[$namespace]); } $configuration = arrayMergeDeep($configuration, $config); $service = "DTS\\eBaySDK\\{$namespace}\\Services\\{$namespace}Service"; return new $service($configuration); } }