From 740ad975bbf0c688cd662daf5517df972a67548c Mon Sep 17 00:00:00 2001 From: Dave van der Brugge Date: Wed, 19 Sep 2018 01:35:21 +0200 Subject: [PATCH] I said **all** traces... --- app/RuleSet/Rules/RulesConverter.php | 86 ---------------------------- 1 file changed, 86 deletions(-) delete mode 100644 app/RuleSet/Rules/RulesConverter.php diff --git a/app/RuleSet/Rules/RulesConverter.php b/app/RuleSet/Rules/RulesConverter.php deleted file mode 100644 index d9ac378..0000000 --- a/app/RuleSet/Rules/RulesConverter.php +++ /dev/null @@ -1,86 +0,0 @@ - []]; - - foreach ($rules as $rule) { - $result['all of'][] = $this->convertRule($transaction, $rule); - } - - return $result; - } - - public function oneOf(IngTransaction $transaction, ...$rules): array - { - $result = ['one of' => []]; - - foreach ($rules as $rule) { - $result['one of'][] = $this->convertRule($transaction, $rule); - } - - return $result; - } - - public function contains(IngTransaction $transaction, $property, $value): string - { - return "{$property} contains {$value}"; - } - - public function equals(IngTransaction $transaction, $property, $value): string - { - return "{$property} equals {$value}"; - } - - public function greaterThan(IngTransaction $transaction, $property, $value): string - { - return "{$property} is greater than {$value}"; - } - - public function isEmpty(IngTransaction $transaction, $property): string - { - return "{$property} is empty"; - } - - public function lessThan(IngTransaction $transaction, $property, $value): string - { - return "{$property} is less than {$value}"; - } - - protected function not(IngTransaction $transaction, ...$arguments): string - { - $result = $this->convertRule($transaction, $arguments); - - [$head, $is_or_tail, $tail] = explode(' ', $result, 3); - - if ($is_or_tail === 'is') { - $head = "{$head} is"; - } else { - $tail = "{$is_or_tail} {$tail}"; - } - - return "{$head} not {$tail}"; - } - - /** - * @return array|string - */ - private function convertRule(IngTransaction $transaction, array $rule) - { - $function = array_shift($rule); - - return $this->{$function}($transaction, ...$rule); - } -}