Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #547 from svrnm/master
Browse files Browse the repository at this point in the history
Fix for 'The first argument to copy() function cannot be a directory'
  • Loading branch information
fzaninotto committed Apr 27, 2015
2 parents 082c744 + 1ca84ea commit e1e2782
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Faker/Provider/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@ public static function file($sourceDirectory = '/tmp', $targetDirectory = '/tmp'
}

// Drop . and .. and reset array keys
$files = array_values(array_diff(scandir($sourceDirectory), array('.', '..')));
$files = array_filter(array_values(array_diff(scandir($sourceDirectory), array('.', '..'))), function ($file) use ($sourceDirectory) {
return !is_dir($sourceDirectory . DIRECTORY_SEPARATOR . $file);
});

$sourceFullPath = $sourceDirectory . DIRECTORY_SEPARATOR . static::randomElement($files);

Expand Down

0 comments on commit e1e2782

Please sign in to comment.