Skip to content

Commit

Permalink
Fix null returning from generator
Browse files Browse the repository at this point in the history
  • Loading branch information
bergice committed Apr 10, 2019
1 parent 3f8b46a commit 8d61fd1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/FilenameParsing/FileIDHelperResolutionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,13 @@ public function findVariants($tuple, Filesystem $filesystem)
}
}

if (!$helper) {
// Could not find the file,
return null;
}

$folder = $helper->lookForVariantIn($parsedFileID);
$possibleVariants = $filesystem->listContents($folder, true);
foreach ($possibleVariants as $possibleVariant) {
if ($possibleVariant['type'] !== 'dir' && $helper->isVariantOf($possibleVariant['path'], $parsedFileID)) {
yield $helper->parseFileID($possibleVariant['path'])->setHash($parsedFileID->getHash());
if ($helper) {
$folder = $helper->lookForVariantIn($parsedFileID);
$possibleVariants = $filesystem->listContents($folder, true);
foreach ($possibleVariants as $possibleVariant) {
if ($possibleVariant['type'] !== 'dir' && $helper->isVariantOf($possibleVariant['path'], $parsedFileID)) {
yield $helper->parseFileID($possibleVariant['path'])->setHash($parsedFileID->getHash());
}
}
}
}
Expand Down

0 comments on commit 8d61fd1

Please sign in to comment.