Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

45 linhas
970B

  1. <?php
  2. namespace Framework\Filesystem\Driver;
  3. use League\Flysystem\Filesystem;
  4. abstract class Driver
  5. {
  6. protected Filesystem $filesystem;
  7. public function __construct(array $config)
  8. {
  9. $this->filesystem = $this->connect($config);
  10. }
  11. abstract protected function connect(array $config): Filesystem;
  12. public function list(string $path, bool $recursive = false): iterable
  13. {
  14. return $this->filesystem->listContents($path, $recursive);
  15. }
  16. public function exists(string $path): bool
  17. {
  18. return $this->filesystem->fileExists($path);
  19. }
  20. public function get(string $path): string
  21. {
  22. return $this->filesystem->read($path);
  23. }
  24. public function put(string $path, mixed $value): static
  25. {
  26. $this->filesystem->write($path, $value);
  27. return $this;
  28. }
  29. public function delete(string $path): static
  30. {
  31. $this->filesystem->delete($path);
  32. return $this;
  33. }
  34. }

Powered by TurnKey Linux.