ListFiles.php 702 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace League\Flysystem\Plugin;
  3. class ListFiles extends AbstractPlugin
  4. {
  5. /**
  6. * Get the method name.
  7. *
  8. * @return string
  9. */
  10. public function getMethod()
  11. {
  12. return 'listFiles';
  13. }
  14. /**
  15. * List all files in the directory.
  16. *
  17. * @param string $directory
  18. * @param bool $recursive
  19. *
  20. * @return array
  21. */
  22. public function handle($directory = '', $recursive = false)
  23. {
  24. $contents = $this->filesystem->listContents($directory, $recursive);
  25. $filter = function ($object) {
  26. return $object['type'] === 'file';
  27. };
  28. return array_values(array_filter($contents, $filter));
  29. }
  30. }