From 8737262a8640038c3279e5ef27258026b73a6a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bar=C3=A1=C5=A1ek?= Date: Thu, 6 Aug 2020 16:08:47 +0200 Subject: [PATCH] Authorizator: Add new method getUnmatchedTransactions() for finding new unknown variables. --- src/BaseAuthorizator.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/BaseAuthorizator.php b/src/BaseAuthorizator.php index e5f0ef3..ec7aad8 100644 --- a/src/BaseAuthorizator.php +++ b/src/BaseAuthorizator.php @@ -36,4 +36,28 @@ public function authOrders(array $unauthorizedVariables, callable $callback, str } } } -} \ No newline at end of file + + + /** + * @param int[] $validVariables + * @return Transaction[] + */ + public function getUnmatchedTransactions(array $validVariables): array + { + $return = []; + foreach ($this->getTransactions() as $transaction) { + $matched = false; + foreach ($validVariables as $currentVariable) { + if ($transaction->isVariableSymbol($currentVariable) === true) { + $matched = true; + break; + } + } + if ($matched === false) { + $return[] = $transaction; + } + } + + return $return; + } +}