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 class AmountExactly implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -41,6 +39,18 @@ class AmountExactly implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/** /**
* @return bool * @return bool
*/ */
@ -62,16 +72,4 @@ class AmountExactly implements TriggerInterface
return false; 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 class AmountLess implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -41,6 +39,18 @@ class AmountLess implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/** /**
* @return bool * @return bool
*/ */
@ -62,16 +72,4 @@ class AmountLess implements TriggerInterface
return false; 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 class AmountMore implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -41,6 +39,18 @@ class AmountMore implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return bccomp('0', $this->trigger->trigger_value) === 0;
}
/** /**
* @return bool * @return bool
*/ */
@ -62,16 +72,4 @@ class AmountMore implements TriggerInterface
return false; 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 class DescriptionContains implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -41,6 +39,18 @@ class DescriptionContains implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @return bool
*/ */
@ -63,16 +73,4 @@ class DescriptionContains implements TriggerInterface
return false; 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 class DescriptionEnds implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class DescriptionEnds implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @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 class DescriptionIs implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class DescriptionIs implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/** /**
* @return bool * @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 class FromAccountContains implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountContains implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @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 class FromAccountEnds implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountEnds implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @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 class FromAccountIs implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountIs implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/** /**
* @return bool * @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 class FromAccountStarts implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class FromAccountStarts implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @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 class ToAccountContains implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountContains implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @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 class ToAccountEnds implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountEnds implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @return bool
*/ */
@ -72,17 +82,4 @@ class ToAccountEnds implements TriggerInterface
return false; 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 class ToAccountIs implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountIs implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/** /**
* @return bool * @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 class ToAccountStarts implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class ToAccountStarts implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return $this->trigger->trigger_value === "";
}
/** /**
* @return bool * @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 class TransactionType implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * TriggerInterface constructor.
@ -40,6 +38,18 @@ class TransactionType implements TriggerInterface
$this->journal = $journal; $this->journal = $journal;
} }
/**
* @{inheritdoc}
*
* @see TriggerInterface::matchesAnything
*
* @return bool
*/
public function matchesAnything()
{
return false;
}
/** /**
* @return bool * @return bool
*/ */
@ -58,16 +68,4 @@ class TransactionType implements TriggerInterface
return false; 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; 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 * Returns the class name to be used for triggers with the given name
* *
@ -47,22 +63,6 @@ class TriggerFactory
return $class; 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 * Returns a map with triggertypes, mapped to the class representing that type
*/ */

View File

@ -21,12 +21,10 @@ use Log;
*/ */
class UserAction implements TriggerInterface class UserAction implements TriggerInterface
{ {
/** @var RuleTrigger */
protected $trigger;
/** @var TransactionJournal */ /** @var TransactionJournal */
protected $journal; protected $journal;
/** @var RuleTrigger */
protected $trigger;
/** /**
* TriggerInterface constructor. * 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} * @{inheritdoc}
* *
@ -65,4 +51,16 @@ class UserAction implements TriggerInterface
return true; 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;
}
} }