Skip to content

Commit

Permalink
Provide static function getLocalFileSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Dec 3, 2023
1 parent e370755 commit 93f46b8
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Resumable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ class Resumable
*/
protected $debug = false;

/** @var string */
public $tempFolder = 'tmp';

/** @var string */
public $uploadFolder = 'test/files/uploads';

/**
Expand Down Expand Up @@ -89,21 +91,25 @@ public function __construct(
?LoggerInterface $logger = null,
?Filesystem $fileSystem = null
) {
$this->request = $request;
$this->response = $response;
$this->fileSystem = $fileSystem === null ? $this->getFileSystem() : $fileSystem;
$this->request = $request;
$this->response = $response;
if ($fileSystem === null) {
$cwd = getcwd();
$cwd === false ? __DIR__ : $cwd;
$this->fileSystem = self::getLocalFileSystem($cwd);
} else {
$this->fileSystem = $fileSystem;
}

$this->logger = $logger;

$this->preProcess();
}

protected function getFileSystem(): Filesystem
public static function getLocalFileSystem(string $baseDir): Filesystem
{
$cwd = getcwd();
$cwd === false ? __DIR__ : $cwd;
$adapter = new LocalFilesystemAdapter(
$cwd
$baseDir
);

return new Filesystem($adapter);
Expand Down

0 comments on commit 93f46b8

Please sign in to comment.