mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code formatting.
This commit is contained in:
parent
b3e18f4e56
commit
52481a6e8b
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 === "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user