Code cleanup. [skip ci]

This commit is contained in:
James Cole 2016-02-17 15:38:21 +01:00
parent 9cac61dc33
commit 0d44f82c86
17 changed files with 240 additions and 277 deletions

View File

@ -22,12 +22,10 @@ use Log;
*/
class AmountExactly implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -41,6 +39,18 @@ class AmountExactly implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/**
* @return bool
*/
@ -62,16 +72,4 @@ class AmountExactly implements TriggerInterface
return false;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
}

View File

@ -22,12 +22,10 @@ use Log;
*/
class AmountLess implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -41,6 +39,18 @@ class AmountLess implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/**
* @return bool
*/
@ -62,16 +72,4 @@ class AmountLess implements TriggerInterface
return false;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
}

View File

@ -22,12 +22,10 @@ use Log;
*/
class AmountMore implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -41,6 +39,18 @@ class AmountMore implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return bccomp('0', $this->trigger->trigger_value) === 0;
}
/**
* @return bool
*/
@ -62,16 +72,4 @@ class AmountMore implements TriggerInterface
return false;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return bccomp('0', $this->trigger->trigger_value) === 0;
}
}

View File

@ -22,12 +22,10 @@ use Log;
*/
class DescriptionContains implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -41,6 +39,18 @@ class DescriptionContains implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -63,16 +73,4 @@ class DescriptionContains implements TriggerInterface
return false;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class DescriptionEnds implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class DescriptionEnds implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -73,16 +83,4 @@ class DescriptionEnds implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class DescriptionIs implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class DescriptionIs implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/**
* @return bool
*/
@ -59,16 +69,4 @@ class DescriptionIs implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class FromAccountContains implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountContains implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -63,16 +73,4 @@ class FromAccountContains implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class FromAccountEnds implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountEnds implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -73,17 +83,4 @@ class FromAccountEnds implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class FromAccountIs implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountIs implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/**
* @return bool
*/
@ -59,16 +69,4 @@ class FromAccountIs implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class FromAccountStarts implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountStarts implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -61,17 +71,4 @@ class FromAccountStarts implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class ToAccountContains implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountContains implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -63,17 +73,4 @@ class ToAccountContains implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class ToAccountEnds implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountEnds implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -72,17 +82,4 @@ class ToAccountEnds implements TriggerInterface
return false;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class ToAccountIs implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountIs implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/**
* @return bool
*/
@ -59,16 +69,4 @@ class ToAccountIs implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class ToAccountStarts implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountStarts implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/**
* @return bool
*/
@ -61,17 +71,4 @@ class ToAccountStarts implements TriggerInterface
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
}

View File

@ -21,12 +21,10 @@ use Log;
*/
class TransactionType implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -40,6 +38,18 @@ class TransactionType implements TriggerInterface
$this->journal = $journal;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/**
* @return bool
*/
@ -58,16 +68,4 @@ class TransactionType implements TriggerInterface
return false;
}
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
}

View File

@ -23,6 +23,22 @@ class TriggerFactory
{
protected static $triggerTypes = null;
/**
* 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
{
$triggerType = $trigger->trigger_type;
$class = self::getTriggerClass($triggerType);
return new $class($trigger, $journal);
}
/**
* Returns the class name to be used for triggers with the given name
*
@ -47,22 +63,6 @@ class TriggerFactory
return $class;
}
/**
* 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
{
$triggerType = $trigger->trigger_type;
$class = self::getTriggerClass($triggerType);
return new $class($trigger, $journal);
}
/**
* Returns a map with triggertypes, mapped to the class representing that type
*/

View File

@ -21,12 +21,10 @@ use Log;
*/
class UserAction implements TriggerInterface
{
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
@ -41,18 +39,6 @@ class UserAction implements TriggerInterface
}
/**
* This trigger is always triggered, because the rule that it is a part of has been pre-selected on this condition.
*
* @return bool
*/
public function triggered()
{
Log::debug('user_action always returns true.');
return true;
}
/**
* @{inheritdoc}
*
@ -65,4 +51,16 @@ class UserAction implements TriggerInterface
return true;
}
/**
* This trigger is always triggered, because the rule that it is a part of has been pre-selected on this condition.
*
* @return bool
*/
public function triggered()
{
Log::debug('user_action always returns true.');
return true;
}
}