/**
  *
  * @param array  $config      Config to be checked
  * @param string $serviceName Name of the service checking (for exception)
  *
  * @throws InvalidServiceConfigException if missing class parameters
  * @throws InvalidServiceCallConfigException if the call config is not valid
  */
 protected function validateServiceConfig(array $config, $serviceName)
 {
     $exceptionArgs = ['serviceName' => $serviceName, 'serviceConfig' => $config];
     if (!isset($config['class'])) {
         throw InvalidServiceConfigException::build([], array_merge($exceptionArgs, ['missingParameter' => 'class']));
     }
     if (isset($config['calls'])) {
         if (!is_array($config['calls'])) {
             throw InvalidServiceCallConfigException::build([], array_merge($exceptionArgs, ['callConfig' => $config['calls']]));
         }
         foreach ($config['calls'] as $callConfigIndex => $callConfig) {
             if (!is_array($callConfig)) {
                 throw InvalidServiceCallConfigException::build([], array_merge($exceptionArgs, ['callConfig' => $callConfig, 'callConfigIndex' => $callConfigIndex]));
             }
             if (isset($callConfig[1]) && !is_array($callConfig[1])) {
                 throw InvalidServiceCallConfigException::build([], array_merge($exceptionArgs, ['callConfig' => $callConfig, 'callConfigIndex' => $callConfigIndex, 'invalidArguments' => $callConfig[1]]));
             }
         }
     }
 }
 /**
  * Registers the services with the application
  */
 public function setupServices()
 {
     $settings = $this->getApp()->container->get('settings');
     if (!empty($settings['services'])) {
         if (!is_array($settings['services'])) {
             throw InvalidServiceConfigException::build([], ['serviceConfig' => $settings['services']]);
         }
         foreach ($settings['services'] as $service => $config) {
             $this->setupService($service, $config);
         }
     }
 }