Skip to content

Commit

Permalink
Replace various string-references to config options with consts
Browse files Browse the repository at this point in the history
  • Loading branch information
jnoordsij committed Nov 18, 2023
1 parent 894b492 commit 22b77fa
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/AsyncAwsS3/AsyncAwsS3Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ public function deleteDirectory(string $path): void

public function createDirectory(string $path, Config $config): void
{
$defaultVisibility = $config->get('directory_visibility', $this->visibility->defaultForDirectories());
$config = $config->withDefaults(['visibility' => $defaultVisibility]);
$defaultVisibility = $config->get(Config::OPTION_DIRECTORY_VISIBILITY, $this->visibility->defaultForDirectories());
$config = $config->withDefaults([Config::OPTION_VISIBILITY => $defaultVisibility]);
$this->upload(rtrim($path, '/') . '/', '', $config);
}

Expand Down
4 changes: 2 additions & 2 deletions src/AwsS3V3/AwsS3V3Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ public function deleteDirectory(string $path): void

public function createDirectory(string $path, Config $config): void
{
$defaultVisibility = $config->get('directory_visibility', $this->visibility->defaultForDirectories());
$config = $config->withDefaults(['visibility' => $defaultVisibility]);
$defaultVisibility = $config->get(Config::OPTION_DIRECTORY_VISIBILITY, $this->visibility->defaultForDirectories());
$config = $config->withDefaults([Config::OPTION_VISIBILITY => $defaultVisibility]);
$this->upload(rtrim($path, '/') . '/', '', $config);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ftp/FtpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function deleteDirectory(string $path): void

public function createDirectory(string $path, Config $config): void
{
$this->ensureDirectoryExists($path, $config->get('directory_visibility', $config->get('visibility')));
$this->ensureDirectoryExists($path, $config->get(Config::OPTION_DIRECTORY_VISIBILITY, $config->get(Config::OPTION_VISIBILITY)));
}

public function setVisibility(string $path, string $visibility): void
Expand Down
4 changes: 2 additions & 2 deletions src/MountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,15 @@ private function copyAcrossFilesystem(
): void {
$config = $this->config->extend($config);
$retainVisibility = (bool) $config->get(Config::OPTION_RETAIN_VISIBILITY, true);
$visibility = $config->get('visibility');
$visibility = $config->get(Config::OPTION_VISIBILITY);

try {
if ($visibility == null && $retainVisibility) {
$visibility = $sourceFilesystem->visibility($sourcePath);
}

$stream = $sourceFilesystem->readStream($sourcePath);
$destinationFilesystem->writeStream($destinationPath, $stream, $visibility ? compact('visibility') : []);
$destinationFilesystem->writeStream($destinationPath, $stream, $visibility ? compact(Config::OPTION_VISIBILITY) : []);
} catch (UnableToRetrieveMetadata | UnableToReadFile | UnableToWriteFile $exception) {
throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpseclibV2/SftpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function copy(string $source, string $destination, Config $config): void
try {
$readStream = $this->readStream($source);
$visibility = $this->visibility($source)->visibility();
$this->writeStream($destination, $readStream, new Config(compact('visibility')));
$this->writeStream($destination, $readStream, new Config(compact(Config::OPTION_VISIBILITY)));
} catch (Throwable $exception) {
if (isset($readStream) && is_resource($readStream)) {
@fclose($readStream);
Expand Down

0 comments on commit 22b77fa

Please sign in to comment.