Skip to content

Commit

Permalink
remove int backing and sort enums + corresponding match statements
Browse files Browse the repository at this point in the history
  • Loading branch information
limenet committed Mar 27, 2024
1 parent 2345607 commit dfcf749
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Enum/ElementInIndexOperation.php
Expand Up @@ -4,10 +4,10 @@

namespace Valantic\ElasticaBridgeBundle\Enum;

enum ElementInIndexOperation: int
enum ElementInIndexOperation
{
case NOTHING = 0;
case DELETE = 1;
case INSERT = 2;
case UPDATE = 3;
case INSERT;
case UPDATE;
case DELETE;
case NOTHING;
}
6 changes: 3 additions & 3 deletions src/Service/PropagateChanges.php
Expand Up @@ -102,8 +102,8 @@ private function doHandleIndex(

$operation = match (true) {
!$isPresent && $shouldIndex => ElementInIndexOperation::INSERT,
$isPresent && !$shouldIndex => ElementInIndexOperation::DELETE,
$isPresent && $shouldIndex => ElementInIndexOperation::UPDATE,
$isPresent && !$shouldIndex => ElementInIndexOperation::DELETE,
default => ElementInIndexOperation::NOTHING,
};

Expand All @@ -114,10 +114,10 @@ private function doHandleIndex(
}

match ($operation) {
ElementInIndexOperation::DELETE => $this->deleteElementFromIndex($element, $elasticaIndex, $document),
ElementInIndexOperation::NOTHING => null,
ElementInIndexOperation::INSERT => $this->addElementToIndex($element, $elasticaIndex, $document),
ElementInIndexOperation::UPDATE => $this->updateElementInIndex($element, $elasticaIndex, $document),
ElementInIndexOperation::DELETE => $this->deleteElementFromIndex($element, $elasticaIndex, $document),
ElementInIndexOperation::NOTHING => null,
};

if (!self::$propagationStopped && !$event->isPropagationStopped()) {
Expand Down

0 comments on commit dfcf749

Please sign in to comment.