Skip to content

Commit

Permalink
More consice naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Oct 19, 2023
1 parent 8cca689 commit 532bb63
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class Config
{
public const OPTION_COPY_DESTINATION_SAME_AS_SOURCE = 'copy_destination_same_as_source';
public const OPTION_MOVE_DESTINATION_SAME_AS_SOURCE = 'move_destination_same_as_source';
public const OPTION_COPY_IDENTICAL_PATH = 'copy_destination_same_as_source';
public const OPTION_MOVE_IDENTICAL_PATH = 'move_destination_same_as_source';
public const OPTION_VISIBILITY = 'visibility';
public const OPTION_DIRECTORY_VISIBILITY = 'directory_visibility';

Expand Down
18 changes: 6 additions & 12 deletions src/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,11 @@ public function move(string $source, string $destination, array $config = []): v
$to = $this->pathNormalizer->normalizePath($destination);

if ($from === $to) {
$resolutionStrategy = $config->get(
Config::OPTION_MOVE_DESTINATION_SAME_AS_SOURCE,
ResolveSameSourceAndDestinationConflict::TRY,
);
$resolutionStrategy = $config->get(Config::OPTION_MOVE_IDENTICAL_PATH, ResolveIdenticalPathConflict::TRY);

if ($resolutionStrategy === ResolveSameSourceAndDestinationConflict::FAIL) {
if ($resolutionStrategy === ResolveIdenticalPathConflict::FAIL) {
throw UnableToMoveFile::sourceAndDestinationAreTheSame($source, $destination);
} elseif ($resolutionStrategy === ResolveSameSourceAndDestinationConflict::IGNORE) {
} elseif ($resolutionStrategy === ResolveIdenticalPathConflict::IGNORE) {
return;
}
}
Expand All @@ -146,14 +143,11 @@ public function copy(string $source, string $destination, array $config = []): v
$to = $this->pathNormalizer->normalizePath($destination);

if ($from === $to) {
$resolutionStrategy = $config->get(
Config::OPTION_COPY_DESTINATION_SAME_AS_SOURCE,
ResolveSameSourceAndDestinationConflict::TRY,
);
$resolutionStrategy = $config->get(Config::OPTION_COPY_IDENTICAL_PATH, ResolveIdenticalPathConflict::TRY);

if ($resolutionStrategy === ResolveSameSourceAndDestinationConflict::FAIL) {
if ($resolutionStrategy === ResolveIdenticalPathConflict::FAIL) {
throw UnableToCopyFile::sourceAndDestinationAreTheSame($source, $destination);
} elseif ($resolutionStrategy === ResolveSameSourceAndDestinationConflict::IGNORE) {
} elseif ($resolutionStrategy === ResolveIdenticalPathConflict::IGNORE) {
return;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ public function ignoring_same_paths_for_move_and_copy(): void
$filesystem = new Filesystem(
new InMemoryFilesystemAdapter(),
[
Config::OPTION_COPY_DESTINATION_SAME_AS_SOURCE => ResolveSameSourceAndDestinationConflict::IGNORE,
Config::OPTION_MOVE_DESTINATION_SAME_AS_SOURCE => ResolveSameSourceAndDestinationConflict::IGNORE,
Config::OPTION_COPY_IDENTICAL_PATH => ResolveIdenticalPathConflict::IGNORE,
Config::OPTION_MOVE_IDENTICAL_PATH => ResolveIdenticalPathConflict::IGNORE,
]
);

Expand All @@ -638,7 +638,7 @@ public function failing_same_paths_for_move(): void
$filesystem = new Filesystem(
new InMemoryFilesystemAdapter(),
[
Config::OPTION_MOVE_DESTINATION_SAME_AS_SOURCE => ResolveSameSourceAndDestinationConflict::FAIL,
Config::OPTION_MOVE_IDENTICAL_PATH => ResolveIdenticalPathConflict::FAIL,
]
);

Expand All @@ -654,7 +654,7 @@ public function failing_same_paths_for_copy(): void
$filesystem = new Filesystem(
new InMemoryFilesystemAdapter(),
[
Config::OPTION_COPY_DESTINATION_SAME_AS_SOURCE => ResolveSameSourceAndDestinationConflict::FAIL,
Config::OPTION_COPY_IDENTICAL_PATH => ResolveIdenticalPathConflict::FAIL,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace League\Flysystem;

class ResolveSameSourceAndDestinationConflict
class ResolveIdenticalPathConflict
{
public const IGNORE = 'ignore';
public const FAIL = 'fail';
Expand Down

0 comments on commit 532bb63

Please sign in to comment.