/**
  * (non-PHPdoc).
  *
  * @see \Mathielen\ImportEngine\Storage\Provider\StorageProviderInterface::storage()
  */
 public function storage(StorageSelection $selection)
 {
     $callable = $selection->getImpl();
     $arguments = array();
     if (is_array($callable) && isset($callable['arguments'])) {
         $arguments = $callable['arguments'];
         unset($callable['arguments']);
     } elseif (!is_callable($callable)) {
         throw new \InvalidArgumentException('StorageSelection must contain a callable or an extended callable (with arguments) as impl');
     }
     return new ServiceStorage($callable, $arguments);
 }
 /**
  * (non-PHPdoc).
  *
  * @see \Mathielen\ImportEngine\Storage\Factory\StorageFactoryInterface::factor()
  */
 public function factor(StorageSelection $selection)
 {
     $file = $selection->getImpl();
     if (!$file instanceof \SplFileInfo) {
         throw new InvalidConfigurationException('StorageSelection does not contain a SplFileInfo as impl property but this is mandatory for a LocalFileStorage.');
     }
     if (!$file->isFile() || !$file->isReadable()) {
         throw new InvalidConfigurationException('StorageSelection references a File that does not exists or is not readable.');
     }
     $format = $selection->getMetadata('format');
     if (!$format) {
         $format = $this->formatDiscoverStrategyInterface->getFormat($selection);
         if (!$format) {
             throw new InvalidConfigurationException('Could not discover format!');
         }
         if ($this->logger) {
             $this->logger->info("File {$file} was discovered as format '{$format}'", ['selection' => $selection->toArray()]);
         }
     }
     $localFile = new LocalFileStorage($file, $format);
     return $localFile;
 }