Skip to content

Commit

Permalink
Fixed tokencollection
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Feb 22, 2024
1 parent a48d62b commit b156e94
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/NotificationCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ public function createTokenCollectionFromArray(array $rawTokens, string $notific
}

foreach (array_merge($flattenedTokens, $rawTokens) as $rawTokenName => $rawTokenValue) {
$addedByDefinition = false;

foreach ($tokenDefinitions as $definition) {
if ($definition->matches($rawTokenName, $rawTokenValue)) {
$token = $definition->createToken($rawTokenName, $rawTokenValue, $stamps);
} else {
$token = Token::fromValue($rawTokenName, $rawTokenValue);
$collection->add($definition->createToken($rawTokenName, $rawTokenValue, $stamps));
$addedByDefinition = true;
break;
}
}

$collection->add($token);
if (!$addedByDefinition) {
$collection->add(Token::fromValue($rawTokenName, $rawTokenValue));
}
}

Expand Down

0 comments on commit b156e94

Please sign in to comment.