Code formatting.

This commit is contained in:
James Cole 2016-02-17 15:29:26 +01:00
parent b3e18f4e56
commit 52481a6e8b
19 changed files with 121 additions and 65 deletions

View File

@ -66,7 +66,11 @@ class AmountExactly implements TriggerInterface
/**
* 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;
}
}

View File

@ -66,7 +66,11 @@ class AmountLess implements TriggerInterface
/**
* 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;
}
}

View File

@ -66,9 +66,11 @@ class AmountMore implements TriggerInterface
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is zero
*
* @return bool
*/
public function matchesAnything() {
public function matchesAnything()
{
return bccomp('0', $this->trigger->trigger_value) === 0;
}
}

View File

@ -67,9 +67,11 @@ class DescriptionContains implements TriggerInterface
/**
* 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 === "";
}
}

View File

@ -76,9 +76,11 @@ class DescriptionEnds implements TriggerInterface
/**
* 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 === "";
}

View File

@ -61,8 +61,12 @@ class DescriptionIs implements TriggerInterface
/**
* Checks whether this trigger will match all transactions
*
* @return bool
*/
public function matchesAnything() { return false; }
public function matchesAnything()
{
return false;
}
}

View File

@ -64,9 +64,11 @@ 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() {
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}

View File

@ -66,9 +66,11 @@ class FromAccountContains implements TriggerInterface
/**
* 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 === "";
}

View File

@ -77,9 +77,11 @@ class FromAccountEnds implements TriggerInterface
/**
* 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 === "";
}

View File

@ -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;
}
}

View File

@ -65,9 +65,11 @@ class FromAccountStarts implements TriggerInterface
/**
* 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 === "";
}

View File

@ -67,9 +67,11 @@ class ToAccountContains implements TriggerInterface
/**
* 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 === "";
}

View File

@ -77,9 +77,11 @@ class ToAccountEnds implements TriggerInterface
/**
* 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 === "";
}
}

View File

@ -61,8 +61,12 @@ class ToAccountIs implements TriggerInterface
/**
* Checks whether this trigger will match all transactions
*
* @return bool
*/
public function matchesAnything() { return false; }
public function matchesAnything()
{
return false;
}
}

View File

@ -65,9 +65,11 @@ class ToAccountStarts implements TriggerInterface
/**
* 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 === "";
}

View File

@ -60,8 +60,12 @@ class TransactionType implements TriggerInterface
/**
* Checks whether this trigger will match all transactions
*
* @return bool
*/
public function matchesAnything() { return false; }
public function matchesAnything()
{
return false;
}
}

View File

@ -25,10 +25,13 @@ class TriggerFactory
/**
* 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)) {
@ -45,11 +48,14 @@ class TriggerFactory
/**
* Returns the trigger for the given type and journal
*
* @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);
@ -59,8 +65,9 @@ class TriggerFactory
/**
* 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();
}

View File

@ -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();
}

View File

@ -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;
}
}