Skip to content

Commit a5d35fc

Browse files
committed
fix: Refactor strategy implementation
Signed-off-by: tmakinde <[email protected]>
1 parent 1d47a57 commit a5d35fc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/implementation/multiprovider/strategy/FirstMatchStrategy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function shouldEvaluateNextProvider(
6161
// Check if error is ThrowableWithResolutionError with FLAG_NOT_FOUND
6262
if ($error instanceof ThrowableWithResolutionError) {
6363
$resolutionError = $error->getResolutionError();
64-
if ($resolutionError->getResolutionErrorCode() === ErrorCode::FLAG_NOT_FOUND()) {
64+
if ($resolutionError->getResolutionErrorCode()->equals(ErrorCode::FLAG_NOT_FOUND())) {
6565
// Continue to next provider for FLAG_NOT_FOUND
6666
return true;
6767
}
@@ -108,7 +108,7 @@ public function determineFinalResult(
108108
$isFlagNotFound = false;
109109
if ($error instanceof ThrowableWithResolutionError) {
110110
$resolutionError = $error->getResolutionError();
111-
if ($resolutionError->getResolutionErrorCode() === ErrorCode::FLAG_NOT_FOUND()) {
111+
if ($resolutionError->getResolutionErrorCode()->equals(ErrorCode::FLAG_NOT_FOUND())) {
112112
$isFlagNotFound = true;
113113
}
114114
}

src/implementation/multiprovider/strategy/FirstSuccessfulStrategy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function shouldEvaluateNextProvider(
4949
StrategyPerProviderContext $context,
5050
ProviderResolutionResult $result,
5151
): bool {
52-
// If we found a successful result, stop here
53-
// Otherwise, continue to next provider (even if there was an error)
54-
return $result->isSuccessful();
52+
// If we found a successful result, stop here (return false)
53+
// Otherwise, continue to next provider (return true)
54+
return !$result->isSuccessful();
5555
}
5656

5757
/**

0 commit comments

Comments
 (0)