original_string: public function createService(ServiceLocatorInterface $serviceLocator)
      {
          $config = $serviceLocator->get('Configuration');
          if (!isset($config['ocr'])) {
              throw new Exception\RuntimeException('No "ocr" section available in configuration.');
          }
          if (!isset($config['ocr']['service'])) {
              throw new Exception\RuntimeException('No "service" specified in "ocr" section of configuration.');
          }
          $service = $serviceLocator->get($config['ocr']['service']);
          if (!$service instanceof OcrServiceInterface) {
              throw new Exception\RuntimeException('Provided service class is not a valid ocr service.');
          }
          if (isset($config['ocr']['config'])) {
              $service->setConfig($config['ocr']['config']);
          }
          return $service;
      }
code: public function createService(ServiceLocatorInterface $serviceLocator)
      {
          $config = $serviceLocator->get('Configuration');
          if (!isset($config['ocr'])) {
              throw new Exception\RuntimeException('No "ocr" section available in configuration.');
          }
          if (!isset($config['ocr']['service'])) {
              throw new Exception\RuntimeException('No "service" specified in "ocr" section of configuration.');
          }
          $service = $serviceLocator->get($config['ocr']['service']);
          if (!$service instanceof OcrServiceInterface) {
              throw new Exception\RuntimeException('Provided service class is not a valid ocr service.');
          }
          if (isset($config['ocr']['config'])) {
              $service->setConfig($config['ocr']['config']);
          }
          return $service;
      }
code_tokens: public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Configuration' ) ; if ( ! isset ( $ config [ 'ocr' ] ) ) { throw new Exception \ RuntimeException ( 'No "ocr" section available in configuration.' ) ; } if ( ! isset ( $ config [ 'ocr' ] [ 'service' ] ) ) { throw new Exception \ RuntimeException ( 'No "service" specified in "ocr" section of configuration.' ) ; } $ service = $ serviceLocator -> get ( $ config [ 'ocr' ] [ 'service' ] ) ; if ( ! $ service instanceof OcrServiceInterface ) { throw new Exception \ RuntimeException ( 'Provided service class is not a valid ocr service.' ) ; } if ( isset ( $ config [ 'ocr' ] [ 'config' ] ) ) { $ service -> setConfig ( $ config [ 'ocr' ] [ 'config' ] ) ; } return $ service ; }
docstring: Create OCR service
  
  @param ServiceLocatorInterface $serviceLocator
  @return OcrServiceInterface
  @throws InvalidArgumentException
docstring_tokens: Create OCR service