Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code formatting.
James Cole52481a6e8b1a
diff --git a/app/Rules/Triggers/AmountExactly.php b/app/Rules/Triggers/AmountExactly.phpindex 998d851dd5..dba3d90867 100644--- a/app/Rules/Triggers/AmountExactly.php+++ b/app/Rules/Triggers/AmountExactly.php@@ -62,11 +62,15 @@ class AmountExactly implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* For example: amount > 0 or description starts with ''+ ** @return bool*/- public function matchesAnything() { return false; }+ public function matchesAnything()+ {+ return false;+ }}diff --git a/app/Rules/Triggers/AmountLess.php b/app/Rules/Triggers/AmountLess.phpindex e90428a233..bf7aaca8cb 100644--- a/app/Rules/Triggers/AmountLess.php+++ b/app/Rules/Triggers/AmountLess.php@@ -62,11 +62,15 @@ class AmountLess implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* For example: amount > 0 or description starts with ''+ ** @return bool*/- public function matchesAnything() { return false; }+ public function matchesAnything()+ {+ return false;+ }}diff --git a/app/Rules/Triggers/AmountMore.php b/app/Rules/Triggers/AmountMore.phpindex 4a1376dfe7..e48df74f3b 100644--- a/app/Rules/Triggers/AmountMore.php+++ b/app/Rules/Triggers/AmountMore.php@@ -62,13 +62,15 @@ class AmountMore implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is zero+ ** @return bool*/- public function matchesAnything() {- return bccomp('0', $this->trigger->trigger_value) === 0;+ public function matchesAnything()+ {+ return bccomp('0', $this->trigger->trigger_value) === 0;}}diff --git a/app/Rules/Triggers/DescriptionContains.php b/app/Rules/Triggers/DescriptionContains.phpindex a26d8628d0..3582f6768e 100644--- a/app/Rules/Triggers/DescriptionContains.php+++ b/app/Rules/Triggers/DescriptionContains.php@@ -63,13 +63,15 @@ class DescriptionContains implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";- }+ }}diff --git a/app/Rules/Triggers/DescriptionEnds.php b/app/Rules/Triggers/DescriptionEnds.phpindex fde345df80..d1b214b37c 100644--- a/app/Rules/Triggers/DescriptionEnds.php+++ b/app/Rules/Triggers/DescriptionEnds.php@@ -72,14 +72,16 @@ class DescriptionEnds implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}-+}diff --git a/app/Rules/Triggers/DescriptionIs.php b/app/Rules/Triggers/DescriptionIs.phpindex 2d38bc46f6..bf1e115371 100644--- a/app/Rules/Triggers/DescriptionIs.php+++ b/app/Rules/Triggers/DescriptionIs.php@@ -58,11 +58,15 @@ class DescriptionIs implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions+ ** @return bool*/- public function matchesAnything() { return false; }-+ public function matchesAnything()+ {+ return false;+ }+}diff --git a/app/Rules/Triggers/DescriptionStarts.php b/app/Rules/Triggers/DescriptionStarts.phpindex 2b41bad3e3..f24fa5cebf 100644--- a/app/Rules/Triggers/DescriptionStarts.php+++ b/app/Rules/Triggers/DescriptionStarts.php@@ -60,14 +60,16 @@ class DescriptionStarts implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}-+}diff --git a/app/Rules/Triggers/FromAccountContains.php b/app/Rules/Triggers/FromAccountContains.phpindex 9da8cbd290..417f69284b 100644--- a/app/Rules/Triggers/FromAccountContains.php+++ b/app/Rules/Triggers/FromAccountContains.php@@ -62,14 +62,16 @@ class FromAccountContains implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}-+}diff --git a/app/Rules/Triggers/FromAccountEnds.php b/app/Rules/Triggers/FromAccountEnds.phpindex 26927c6370..798fee6bc4 100644--- a/app/Rules/Triggers/FromAccountEnds.php+++ b/app/Rules/Triggers/FromAccountEnds.php@@ -72,15 +72,17 @@ class FromAccountEnds implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}-+}diff --git a/app/Rules/Triggers/FromAccountIs.php b/app/Rules/Triggers/FromAccountIs.phpindex 1cdbc30521..98b294e7ad 100644--- a/app/Rules/Triggers/FromAccountIs.php+++ b/app/Rules/Triggers/FromAccountIs.php@@ -61,8 +61,12 @@ class FromAccountIs implements TriggerInterface/*** Checks whether this trigger will match all transactions+ ** @return bool*/- public function matchesAnything() { return false; }-+ public function matchesAnything()+ {+ return false;+ }+}diff --git a/app/Rules/Triggers/FromAccountStarts.php b/app/Rules/Triggers/FromAccountStarts.phpindex 43e8f915b9..b88fb2739b 100644--- a/app/Rules/Triggers/FromAccountStarts.php+++ b/app/Rules/Triggers/FromAccountStarts.php@@ -60,15 +60,17 @@ class FromAccountStarts implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}-+}diff --git a/app/Rules/Triggers/ToAccountContains.php b/app/Rules/Triggers/ToAccountContains.phpindex 0e291a904a..1431f8c8bb 100644--- a/app/Rules/Triggers/ToAccountContains.php+++ b/app/Rules/Triggers/ToAccountContains.php@@ -62,15 +62,17 @@ class ToAccountContains implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}-+}diff --git a/app/Rules/Triggers/ToAccountEnds.php b/app/Rules/Triggers/ToAccountEnds.phpindex 60784e4b6f..5ddccd7a96 100644--- a/app/Rules/Triggers/ToAccountEnds.php+++ b/app/Rules/Triggers/ToAccountEnds.php@@ -72,14 +72,16 @@ class ToAccountEnds implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}}diff --git a/app/Rules/Triggers/ToAccountIs.php b/app/Rules/Triggers/ToAccountIs.phpindex f11fdf272f..409d29ba2c 100644--- a/app/Rules/Triggers/ToAccountIs.php+++ b/app/Rules/Triggers/ToAccountIs.php@@ -58,11 +58,15 @@ class ToAccountIs implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions+ ** @return bool*/- public function matchesAnything() { return false; }-+ public function matchesAnything()+ {+ return false;+ }+}diff --git a/app/Rules/Triggers/ToAccountStarts.php b/app/Rules/Triggers/ToAccountStarts.phpindex bf0ca5f5d7..6eeab8e06d 100644--- a/app/Rules/Triggers/ToAccountStarts.php+++ b/app/Rules/Triggers/ToAccountStarts.php@@ -60,15 +60,17 @@ class ToAccountStarts implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions* This happens when the trigger_value is empty+ ** @return bool*/- public function matchesAnything() {+ public function matchesAnything()+ {return $this->trigger->trigger_value === "";}-+}diff --git a/app/Rules/Triggers/TransactionType.php b/app/Rules/Triggers/TransactionType.phpindex 4d46520d50..dbd17c1b47 100644--- a/app/Rules/Triggers/TransactionType.php+++ b/app/Rules/Triggers/TransactionType.php@@ -57,11 +57,15 @@ class TransactionType implements TriggerInterfacereturn false;}-+/*** Checks whether this trigger will match all transactions+ ** @return bool*/- public function matchesAnything() { return false; }-+ public function matchesAnything()+ {+ return false;+ }+}diff --git a/app/Rules/Triggers/TriggerFactory.php b/app/Rules/Triggers/TriggerFactory.phpindex cb7c68efd2..8c2a38d8f4 100644--- a/app/Rules/Triggers/TriggerFactory.php+++ b/app/Rules/Triggers/TriggerFactory.php@@ -22,48 +22,55 @@ use FireflyIII\Support\Domain;class TriggerFactory{protected static $triggerTypes = null;-+/*** Returns the class name to be used for triggers with the given name+ ** @param string $triggerType+ ** @return TriggerInterface*/- public static function getTriggerClass(string $triggerType): string {+ public static function getTriggerClass(string $triggerType): string+ {$triggerTypes = self::getTriggerTypes();-+if (!array_key_exists($triggerType, $triggerTypes)) {abort(500, 'No such trigger exists ("' . $triggerType . '").');}-+$class = $triggerTypes[$triggerType];if (!class_exists($class)) {abort(500, 'Could not instantiate class for rule trigger type "' . $triggerType . '" (' . $class . ').');}-+return $class;}-+/*** Returns the trigger for the given type and journal- * @param RuleTrigger $trigger+ *+ * @param RuleTrigger $trigger* @param TransactionJournal $journal+ ** @return TriggerInterface*/- public static function getTrigger(RuleTrigger $trigger, TransactionJournal $journal): TriggerInterface {+ public static function getTrigger(RuleTrigger $trigger, TransactionJournal $journal): TriggerInterface+ {$triggerType = $trigger->trigger_type;- $class = self::getTriggerClass($triggerType);-+ $class = self::getTriggerClass($triggerType);+return new $class($trigger, $journal);}-+/*** Returns a map with triggertypes, mapped to the class representing that type*/- protected static function getTriggerTypes() {- if( !self::$triggerTypes ) {+ protected static function getTriggerTypes()+ {+ if (!self::$triggerTypes) {self::$triggerTypes = Domain::getRuleTriggers();}-+return self::$triggerTypes;}}diff --git a/app/Rules/Triggers/TriggerInterface.php b/app/Rules/Triggers/TriggerInterface.phpindex 5a653a9d9f..76ae6052bb 100644--- a/app/Rules/Triggers/TriggerInterface.php+++ b/app/Rules/Triggers/TriggerInterface.php@@ -28,15 +28,16 @@ interface TriggerInterface*/public function __construct(RuleTrigger $trigger, TransactionJournal $journal);- /**- * @return bool- */- public function triggered();-/*** Checks whether this trigger will match all transactions* For example: amount > 0 or description starts with ''+ ** @return bool*/public function matchesAnything();++ /**+ * @return bool+ */+ public function triggered();}diff --git a/app/Rules/Triggers/UserAction.php b/app/Rules/Triggers/UserAction.phpindex 4e576bd573..475ec8a82e 100644--- a/app/Rules/Triggers/UserAction.php+++ b/app/Rules/Triggers/UserAction.php@@ -55,8 +55,12 @@ class UserAction implements TriggerInterface/*** Checks whether this trigger will match all transactions+ ** @return bool*/- public function matchesAnything() { return true; }-+ public function matchesAnything()+ {+ return true;+ }+}