Skip to content

Firefly III: a personal finances manager

Better description for matchesAnything

James Cole9cac61dc3321
diff --git a/app/Rules/Triggers/AmountExactly.php b/app/Rules/Triggers/AmountExactly.php
index dba3d90867..a9e13cf388 100644
--- a/app/Rules/Triggers/AmountExactly.php
+++ b/app/Rules/Triggers/AmountExactly.php
@@ -64,8 +64,9 @@ class AmountExactly implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
- * For example: amount > 0 or description starts with ''
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/AmountLess.php b/app/Rules/Triggers/AmountLess.php
index bf7aaca8cb..29e38e181b 100644
--- a/app/Rules/Triggers/AmountLess.php
+++ b/app/Rules/Triggers/AmountLess.php
@@ -64,8 +64,9 @@ class AmountLess implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
- * For example: amount > 0 or description starts with ''
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/AmountMore.php b/app/Rules/Triggers/AmountMore.php
index e48df74f3b..583d893ddc 100644
--- a/app/Rules/Triggers/AmountMore.php
+++ b/app/Rules/Triggers/AmountMore.php
@@ -64,8 +64,9 @@ class AmountMore implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is zero
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/DescriptionContains.php b/app/Rules/Triggers/DescriptionContains.php
index 3582f6768e..cd639078c0 100644
--- a/app/Rules/Triggers/DescriptionContains.php
+++ b/app/Rules/Triggers/DescriptionContains.php
@@ -65,8 +65,9 @@ class DescriptionContains implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/DescriptionEnds.php b/app/Rules/Triggers/DescriptionEnds.php
index d1b214b37c..0eb3c99f83 100644
--- a/app/Rules/Triggers/DescriptionEnds.php
+++ b/app/Rules/Triggers/DescriptionEnds.php
@@ -74,8 +74,9 @@ class DescriptionEnds implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/DescriptionIs.php b/app/Rules/Triggers/DescriptionIs.php
index bf1e115371..5d1011bf6a 100644
--- a/app/Rules/Triggers/DescriptionIs.php
+++ b/app/Rules/Triggers/DescriptionIs.php
@@ -60,7 +60,9 @@ class DescriptionIs implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/DescriptionStarts.php b/app/Rules/Triggers/DescriptionStarts.php
index f24fa5cebf..f5ad96953d 100644
--- a/app/Rules/Triggers/DescriptionStarts.php
+++ b/app/Rules/Triggers/DescriptionStarts.php
@@ -21,12 +21,10 @@ use Log;
*/
class DescriptionStarts implements TriggerInterface
{
- /** @var RuleTrigger */
- protected $trigger;
-
/** @var TransactionJournal */
protected $journal;
-
+ /** @var RuleTrigger */
+ protected $trigger;
/**
* TriggerInterface constructor.
@@ -40,6 +38,18 @@ class DescriptionStarts implements TriggerInterface
$this->journal = $journal;
}
+ /**
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
+ *
+ * @return bool
+ */
+ public function matchesAnything()
+ {
+ return $this->trigger->trigger_value === "";
+ }
+
/**
* @return bool
*/
@@ -61,15 +71,4 @@ class DescriptionStarts implements TriggerInterface
}
- /**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
- *
- * @return bool
- */
- public function matchesAnything()
- {
- return $this->trigger->trigger_value === "";
- }
-
}
diff --git a/app/Rules/Triggers/FromAccountContains.php b/app/Rules/Triggers/FromAccountContains.php
index 417f69284b..e7bd31ed5d 100644
--- a/app/Rules/Triggers/FromAccountContains.php
+++ b/app/Rules/Triggers/FromAccountContains.php
@@ -64,8 +64,9 @@ class FromAccountContains implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/FromAccountEnds.php b/app/Rules/Triggers/FromAccountEnds.php
index 798fee6bc4..bba52c85c5 100644
--- a/app/Rules/Triggers/FromAccountEnds.php
+++ b/app/Rules/Triggers/FromAccountEnds.php
@@ -75,8 +75,9 @@ class FromAccountEnds implements TriggerInterface
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/FromAccountIs.php b/app/Rules/Triggers/FromAccountIs.php
index 98b294e7ad..90d38ca6d9 100644
--- a/app/Rules/Triggers/FromAccountIs.php
+++ b/app/Rules/Triggers/FromAccountIs.php
@@ -60,7 +60,9 @@ class FromAccountIs implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/FromAccountStarts.php b/app/Rules/Triggers/FromAccountStarts.php
index b88fb2739b..43a8f5b7a0 100644
--- a/app/Rules/Triggers/FromAccountStarts.php
+++ b/app/Rules/Triggers/FromAccountStarts.php
@@ -63,8 +63,9 @@ class FromAccountStarts implements TriggerInterface
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/ToAccountContains.php b/app/Rules/Triggers/ToAccountContains.php
index 1431f8c8bb..c219437e8b 100644
--- a/app/Rules/Triggers/ToAccountContains.php
+++ b/app/Rules/Triggers/ToAccountContains.php
@@ -65,8 +65,9 @@ class ToAccountContains implements TriggerInterface
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/ToAccountEnds.php b/app/Rules/Triggers/ToAccountEnds.php
index 5ddccd7a96..5591ffcca8 100644
--- a/app/Rules/Triggers/ToAccountEnds.php
+++ b/app/Rules/Triggers/ToAccountEnds.php
@@ -75,8 +75,9 @@ class ToAccountEnds implements TriggerInterface
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/ToAccountIs.php b/app/Rules/Triggers/ToAccountIs.php
index 409d29ba2c..4596ef9fde 100644
--- a/app/Rules/Triggers/ToAccountIs.php
+++ b/app/Rules/Triggers/ToAccountIs.php
@@ -60,7 +60,9 @@ class ToAccountIs implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/ToAccountStarts.php b/app/Rules/Triggers/ToAccountStarts.php
index 6eeab8e06d..d4423e931a 100644
--- a/app/Rules/Triggers/ToAccountStarts.php
+++ b/app/Rules/Triggers/ToAccountStarts.php
@@ -63,8 +63,9 @@ class ToAccountStarts implements TriggerInterface
/**
- * Checks whether this trigger will match all transactions
- * This happens when the trigger_value is empty
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/TransactionType.php b/app/Rules/Triggers/TransactionType.php
index dbd17c1b47..3a06c13f30 100644
--- a/app/Rules/Triggers/TransactionType.php
+++ b/app/Rules/Triggers/TransactionType.php
@@ -59,7 +59,9 @@ class TransactionType implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/
diff --git a/app/Rules/Triggers/TriggerFactory.php b/app/Rules/Triggers/TriggerFactory.php
index 8c2a38d8f4..157861889c 100644
--- a/app/Rules/Triggers/TriggerFactory.php
+++ b/app/Rules/Triggers/TriggerFactory.php
@@ -38,6 +38,7 @@ class TriggerFactory
abort(500, 'No such trigger exists ("' . $triggerType . '").');
}
+ /** @var TriggerInterface $class */
$class = $triggerTypes[$triggerType];
if (!class_exists($class)) {
abort(500, 'Could not instantiate class for rule trigger type "' . $triggerType . '" (' . $class . ').');
diff --git a/app/Rules/Triggers/TriggerInterface.php b/app/Rules/Triggers/TriggerInterface.php
index 76ae6052bb..2c8f61f4f8 100644
--- a/app/Rules/Triggers/TriggerInterface.php
+++ b/app/Rules/Triggers/TriggerInterface.php
@@ -29,8 +29,16 @@ interface TriggerInterface
public function __construct(RuleTrigger $trigger, TransactionJournal $journal);
/**
- * Checks whether this trigger will match all transactions
- * For example: amount > 0 or description starts with ''
+ * A trigger is said to "match anything", or match any given transaction,
+ * when the trigger value is very vague or has no restrictions. Easy examples
+ * are the "AmountMore"-trigger combined with an amount of 0: any given transaction
+ * has an amount of more than zero! Other examples are all the "Description"-triggers
+ * which have hard time handling empty trigger values such as "" or "*" (wild cards).
+ *
+ * If the user tries to create such a trigger, this method MUST return true so Firefly III
+ * can stop the storing / updating the trigger. If the trigger is in any way restrictive
+ * (even if it will still include 99.9% of the users transactions), this method MUST return
+ * false.
*
* @return bool
*/
diff --git a/app/Rules/Triggers/UserAction.php b/app/Rules/Triggers/UserAction.php
index 475ec8a82e..55ab4dbfda 100644
--- a/app/Rules/Triggers/UserAction.php
+++ b/app/Rules/Triggers/UserAction.php
@@ -54,7 +54,9 @@ class UserAction implements TriggerInterface
}
/**
- * Checks whether this trigger will match all transactions
+ * @{inheritdoc}
+ *
+ * @see TriggerInterface::matchesAnything
*
* @return bool
*/