From 52481a6e8b1aa19afdd516a77aa5939c41bb9194 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 17 Feb 2016 15:29:26 +0100 Subject: [PATCH] Code formatting. --- app/Rules/Triggers/AmountExactly.php | 8 +++-- app/Rules/Triggers/AmountLess.php | 8 +++-- app/Rules/Triggers/AmountMore.php | 8 +++-- app/Rules/Triggers/DescriptionContains.php | 8 +++-- app/Rules/Triggers/DescriptionEnds.php | 8 +++-- app/Rules/Triggers/DescriptionIs.php | 10 +++++-- app/Rules/Triggers/DescriptionStarts.php | 8 +++-- app/Rules/Triggers/FromAccountContains.php | 8 +++-- app/Rules/Triggers/FromAccountEnds.php | 8 +++-- app/Rules/Triggers/FromAccountIs.php | 8 +++-- app/Rules/Triggers/FromAccountStarts.php | 8 +++-- app/Rules/Triggers/ToAccountContains.php | 8 +++-- app/Rules/Triggers/ToAccountEnds.php | 6 ++-- app/Rules/Triggers/ToAccountIs.php | 10 +++++-- app/Rules/Triggers/ToAccountStarts.php | 8 +++-- app/Rules/Triggers/TransactionType.php | 10 +++++-- app/Rules/Triggers/TriggerFactory.php | 35 +++++++++++++--------- app/Rules/Triggers/TriggerInterface.php | 11 +++---- app/Rules/Triggers/UserAction.php | 8 +++-- 19 files changed, 121 insertions(+), 65 deletions(-) diff --git a/app/Rules/Triggers/AmountExactly.php b/app/Rules/Triggers/AmountExactly.php index 998d851dd5..dba3d90867 100644 --- a/app/Rules/Triggers/AmountExactly.php +++ b/app/Rules/Triggers/AmountExactly.php @@ -62,11 +62,15 @@ class AmountExactly implements TriggerInterface return 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.php index e90428a233..bf7aaca8cb 100644 --- a/app/Rules/Triggers/AmountLess.php +++ b/app/Rules/Triggers/AmountLess.php @@ -62,11 +62,15 @@ class AmountLess implements TriggerInterface return 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.php index 4a1376dfe7..e48df74f3b 100644 --- a/app/Rules/Triggers/AmountMore.php +++ b/app/Rules/Triggers/AmountMore.php @@ -62,13 +62,15 @@ class AmountMore implements TriggerInterface return 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.php index a26d8628d0..3582f6768e 100644 --- a/app/Rules/Triggers/DescriptionContains.php +++ b/app/Rules/Triggers/DescriptionContains.php @@ -63,13 +63,15 @@ class DescriptionContains implements TriggerInterface return 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.php index fde345df80..d1b214b37c 100644 --- a/app/Rules/Triggers/DescriptionEnds.php +++ b/app/Rules/Triggers/DescriptionEnds.php @@ -72,14 +72,16 @@ class DescriptionEnds implements TriggerInterface return 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.php index 2d38bc46f6..bf1e115371 100644 --- a/app/Rules/Triggers/DescriptionIs.php +++ b/app/Rules/Triggers/DescriptionIs.php @@ -58,11 +58,15 @@ class DescriptionIs implements TriggerInterface return 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.php index 2b41bad3e3..f24fa5cebf 100644 --- a/app/Rules/Triggers/DescriptionStarts.php +++ b/app/Rules/Triggers/DescriptionStarts.php @@ -60,14 +60,16 @@ class DescriptionStarts implements TriggerInterface return 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.php index 9da8cbd290..417f69284b 100644 --- a/app/Rules/Triggers/FromAccountContains.php +++ b/app/Rules/Triggers/FromAccountContains.php @@ -62,14 +62,16 @@ class FromAccountContains implements TriggerInterface return 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.php index 26927c6370..798fee6bc4 100644 --- a/app/Rules/Triggers/FromAccountEnds.php +++ b/app/Rules/Triggers/FromAccountEnds.php @@ -72,15 +72,17 @@ class FromAccountEnds implements TriggerInterface return 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.php index 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.php index 43e8f915b9..b88fb2739b 100644 --- a/app/Rules/Triggers/FromAccountStarts.php +++ b/app/Rules/Triggers/FromAccountStarts.php @@ -60,15 +60,17 @@ class FromAccountStarts implements TriggerInterface return 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.php index 0e291a904a..1431f8c8bb 100644 --- a/app/Rules/Triggers/ToAccountContains.php +++ b/app/Rules/Triggers/ToAccountContains.php @@ -62,15 +62,17 @@ class ToAccountContains implements TriggerInterface return 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.php index 60784e4b6f..5ddccd7a96 100644 --- a/app/Rules/Triggers/ToAccountEnds.php +++ b/app/Rules/Triggers/ToAccountEnds.php @@ -72,14 +72,16 @@ class ToAccountEnds implements TriggerInterface return 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.php index f11fdf272f..409d29ba2c 100644 --- a/app/Rules/Triggers/ToAccountIs.php +++ b/app/Rules/Triggers/ToAccountIs.php @@ -58,11 +58,15 @@ class ToAccountIs implements TriggerInterface return 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.php index bf0ca5f5d7..6eeab8e06d 100644 --- a/app/Rules/Triggers/ToAccountStarts.php +++ b/app/Rules/Triggers/ToAccountStarts.php @@ -60,15 +60,17 @@ class ToAccountStarts implements TriggerInterface return 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.php index 4d46520d50..dbd17c1b47 100644 --- a/app/Rules/Triggers/TransactionType.php +++ b/app/Rules/Triggers/TransactionType.php @@ -57,11 +57,15 @@ class TransactionType implements TriggerInterface return 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.php index 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.php index 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.php index 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; + } + }