private function parseSource(Source $source, Filter $parentFilter = null) { $filter = new Filter($parentFilter, $source->getName(), $source->getExtensions()); foreach ($source->getSources() as $subSource) { $this->parseSource($subSource, $filter); } foreach ($source->getPaths() as $path) { if (is_dir($path)) { $this->parseDirectory($path, $filter, $source->getExpand()); } elseif (is_file($path)) { $filter->addFile($path); } else { throw new RuntimeException(sprintf('The path "%s" does not exists.', $path)); } } return $filter; }