Changed trigger constructor. No longer needs model AND journal, now only model. Wait for it...

This commit is contained in:
James Cole
2016-02-17 19:07:20 +01:00
parent 8024ad123e
commit 12b6791e8b
20 changed files with 347 additions and 332 deletions

View File

@@ -112,9 +112,9 @@ class Processor
foreach ($this->triggers as $trigger) {
$foundTriggers++;
/** @var TriggerInterface $triggerClass */
$triggerClass = TriggerFactory::getTrigger($trigger, $this->journal);
if ($triggerClass->triggered()) {
/** @var TriggerInterface $triggerObject */
$triggerObject = TriggerFactory::getTrigger($trigger);
if ($triggerObject->triggered()) {
$hitTriggers++;
}
if ($trigger->stop_processing) {

View File

@@ -22,21 +22,19 @@ use Log;
*/
class AmountExactly implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
@@ -65,11 +63,13 @@ class AmountExactly implements TriggerInterface
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
$amount = $this->journal->amount_positive;
$amount = $journal->amount_positive;
$compare = $this->trigger->trigger_value;
$result = bccomp($amount, $compare, 4);
if ($result === 0) {

View File

@@ -22,21 +22,20 @@ use Log;
*/
class AmountLess implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
@@ -65,11 +64,13 @@ class AmountLess implements TriggerInterface
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
$amount = $this->journal->amount_positive;
$amount = $journal->amount_positive;
$compare = $this->trigger->trigger_value;
$result = bccomp($amount, $compare, 4);
if ($result === -1) {

View File

@@ -22,21 +22,20 @@ use Log;
*/
class AmountMore implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
@@ -65,11 +64,13 @@ class AmountMore implements TriggerInterface
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
$amount = $this->journal->amount_positive;
$amount = $journal->amount_positive;
$compare = $this->trigger->trigger_value;
$result = bccomp($amount, $compare, 4);
if ($result === 1) {

View File

@@ -22,21 +22,20 @@ use Log;
*/
class DescriptionContains implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
@@ -65,12 +64,14 @@ class DescriptionContains implements TriggerInterface
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
$search = strtolower($this->trigger->trigger_value);
$source = strtolower($this->journal->description);
$source = strtolower($journal->description);
$strpos = strpos($source, $search);
if (!($strpos === false)) {

View File

@@ -21,21 +21,20 @@ use Log;
*/
class DescriptionEnds implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
@@ -64,11 +63,13 @@ class DescriptionEnds implements TriggerInterface
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
$description = strtolower($this->journal->description);
$description = strtolower($journal->description);
$descriptionLength = strlen($description);
$search = strtolower($this->trigger->trigger_value);
$searchLength = strlen($search);

View File

@@ -21,39 +21,19 @@ use Log;
*/
class DescriptionIs implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$description = strtolower($this->journal->description);
$search = strtolower($this->trigger->trigger_value);
if ($description == $search) {
Log::debug('"' . $description . '" equals "' . $search . '" exactly. Return true.');
return true;
}
Log::debug('"' . $description . '" does not equal "' . $search . '". Return false.');
return false;
}
@@ -81,4 +61,25 @@ class DescriptionIs implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$description = strtolower($journal->description);
$search = strtolower($this->trigger->trigger_value);
if ($description == $search) {
Log::debug('"' . $description . '" equals "' . $search . '" exactly. Return true.');
return true;
}
Log::debug('"' . $description . '" does not equal "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,41 +21,19 @@ use Log;
*/
class DescriptionStarts implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$description = strtolower($this->journal->description);
$search = strtolower($this->trigger->trigger_value);
$part = substr($description, 0, strlen($search));
if ($part == $search) {
Log::debug('"' . $description . '" starts with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $description . '" does not start with "' . $search . '". Return false.');
return false;
}
@@ -83,4 +61,27 @@ class DescriptionStarts implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$description = strtolower($journal->description);
$search = strtolower($this->trigger->trigger_value);
$part = substr($description, 0, strlen($search));
if ($part == $search) {
Log::debug('"' . $description . '" starts with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $description . '" does not start with "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,43 +21,19 @@ use Log;
*/
class FromAccountContains implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$fromAccountName = strtolower($this->journal->source_account->name);
$search = strtolower($this->trigger->trigger_value);
$strpos = strpos($fromAccountName, $search);
if (!($strpos === false)) {
// found something
Log::debug('"' . $fromAccountName . '" contains the text "' . $search . '". Return true.');
return true;
}
// found nothing.
Log::debug('"' . $fromAccountName . '" does not contain the text "' . $search . '". Return false.');
return false;
}
@@ -85,4 +61,29 @@ class FromAccountContains implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$fromAccountName = strtolower($journal->source_account->name);
$search = strtolower($this->trigger->trigger_value);
$strpos = strpos($fromAccountName, $search);
if (!($strpos === false)) {
// found something
Log::debug('"' . $fromAccountName . '" contains the text "' . $search . '". Return true.');
return true;
}
// found nothing.
Log::debug('"' . $fromAccountName . '" does not contain the text "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,53 +21,19 @@ use Log;
*/
class FromAccountEnds implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$name = strtolower($this->journal->source_account->name);
$nameLength = strlen($name);
$search = strtolower($this->trigger->trigger_value);
$searchLength = strlen($search);
// if the string to search for is longer than the account name,
// shorten the search string.
if ($searchLength > $nameLength) {
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $name . '" (' . $nameLength . '). ');
$search = substr($search, ($nameLength * -1));
$searchLength = strlen($search);
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
}
$part = substr($name, $searchLength * -1);
if ($part == $search) {
Log::debug('"' . $name . '" ends with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $name . '" does not end with "' . $search . '". Return false.');
return false;
}
@@ -95,4 +61,39 @@ class FromAccountEnds implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$name = strtolower($journal->source_account->name);
$nameLength = strlen($name);
$search = strtolower($this->trigger->trigger_value);
$searchLength = strlen($search);
// if the string to search for is longer than the account name,
// shorten the search string.
if ($searchLength > $nameLength) {
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $name . '" (' . $nameLength . '). ');
$search = substr($search, ($nameLength * -1));
$searchLength = strlen($search);
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
}
$part = substr($name, $searchLength * -1);
if ($part == $search) {
Log::debug('"' . $name . '" ends with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $name . '" does not end with "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,21 +21,20 @@ use Log;
*/
class FromAccountIs implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
@@ -64,11 +63,13 @@ class FromAccountIs implements TriggerInterface
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
$fromAccountName = strtolower($this->journal->source_account->name);
$fromAccountName = strtolower($journal->source_account->name);
$search = strtolower($this->trigger->trigger_value);
if ($fromAccountName == $search) {

View File

@@ -21,21 +21,20 @@ use Log;
*/
class FromAccountStarts implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
@@ -64,11 +63,13 @@ class FromAccountStarts implements TriggerInterface
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
$fromAccountName = strtolower($this->journal->source_account->name);
$fromAccountName = strtolower($journal->source_account->name);
$search = strtolower($this->trigger->trigger_value);
$part = substr($fromAccountName, 0, strlen($search));

View File

@@ -21,47 +21,22 @@ use Log;
*/
class ToAccountContains implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$toAccountName = strtolower($this->journal->destination_account->name);
$search = strtolower($this->trigger->trigger_value);
$strpos = strpos($toAccountName, $search);
if (!($strpos === false)) {
// found something
Log::debug('"' . $toAccountName . '" contains the text "' . $search . '". Return true.');
return true;
}
// found nothing.
Log::debug('"' . $toAccountName . '" does not contain the text "' . $search . '". Return false.');
return false;
}
/**
* A trigger is said to "match anything", or match any given transaction,
* when the trigger value is very vague or has no restrictions. Easy examples
@@ -86,4 +61,29 @@ class ToAccountContains implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$toAccountName = strtolower($journal->destination_account->name);
$search = strtolower($this->trigger->trigger_value);
$strpos = strpos($toAccountName, $search);
if (!($strpos === false)) {
// found something
Log::debug('"' . $toAccountName . '" contains the text "' . $search . '". Return true.');
return true;
}
// found nothing.
Log::debug('"' . $toAccountName . '" does not contain the text "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,53 +21,19 @@ use Log;
*/
class ToAccountEnds implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$toAccountName = strtolower($this->journal->destination_account->name);
$toAccountNameLength = strlen($toAccountName);
$search = strtolower($this->trigger->trigger_value);
$searchLength = strlen($search);
// if the string to search for is longer than the account name,
// shorten the search string.
if ($searchLength > $toAccountNameLength) {
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $toAccountName . '" (' . $toAccountNameLength . '). ');
$search = substr($search, ($toAccountNameLength * -1));
$searchLength = strlen($search);
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
}
$part = substr($toAccountName, $searchLength * -1);
if ($part == $search) {
Log::debug('"' . $toAccountName . '" ends with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $toAccountName . '" does not end with "' . $search . '". Return false.');
return false;
}
@@ -95,4 +61,39 @@ class ToAccountEnds implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$toAccountName = strtolower($journal->destination_account->name);
$toAccountNameLength = strlen($toAccountName);
$search = strtolower($this->trigger->trigger_value);
$searchLength = strlen($search);
// if the string to search for is longer than the account name,
// shorten the search string.
if ($searchLength > $toAccountNameLength) {
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $toAccountName . '" (' . $toAccountNameLength . '). ');
$search = substr($search, ($toAccountNameLength * -1));
$searchLength = strlen($search);
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
}
$part = substr($toAccountName, $searchLength * -1);
if ($part == $search) {
Log::debug('"' . $toAccountName . '" ends with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $toAccountName . '" does not end with "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,39 +21,19 @@ use Log;
*/
class ToAccountIs implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$toAccountName = strtolower($this->journal->destination_account->name);
$search = strtolower($this->trigger->trigger_value);
if ($toAccountName == $search) {
Log::debug('"' . $toAccountName . '" equals "' . $search . '" exactly. Return true.');
return true;
}
Log::debug('"' . $toAccountName . '" does not equal "' . $search . '". Return false.');
return false;
}
@@ -81,4 +61,25 @@ class ToAccountIs implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$toAccountName = strtolower($journal->destination_account->name);
$search = strtolower($this->trigger->trigger_value);
if ($toAccountName == $search) {
Log::debug('"' . $toAccountName . '" equals "' . $search . '" exactly. Return true.');
return true;
}
Log::debug('"' . $toAccountName . '" does not equal "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,41 +21,19 @@ use Log;
*/
class ToAccountStarts implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$toAccountName = strtolower($this->journal->destination_account->name);
$search = strtolower($this->trigger->trigger_value);
$part = substr($toAccountName, 0, strlen($search));
if ($part == $search) {
Log::debug('"' . $toAccountName . '" starts with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $toAccountName . '" does not start with "' . $search . '". Return false.');
return false;
}
@@ -83,4 +61,27 @@ class ToAccountStarts implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$toAccountName = strtolower($journal->destination_account->name);
$search = strtolower($this->trigger->trigger_value);
$part = substr($toAccountName, 0, strlen($search));
if ($part == $search) {
Log::debug('"' . $toAccountName . '" starts with "' . $search . '". Return true.');
return true;
}
Log::debug('"' . $toAccountName . '" does not start with "' . $search . '". Return false.');
return false;
}
}

View File

@@ -21,39 +21,20 @@ use Log;
*/
class TransactionType implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
/**
* @return bool
*/
public function triggered()
{
$type = strtolower($this->journal->transactionType->type);
$search = strtolower($this->trigger->trigger_value);
if ($type == $search) {
Log::debug('Journal is of type "' . $type . '" which matches with "' . $search . '". Return true');
return true;
}
Log::debug('Journal is of type "' . $type . '" which does not match with "' . $search . '". Return false');
return false;
}
/**
@@ -80,4 +61,24 @@ class TransactionType implements TriggerInterface
return true;
}
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered(TransactionJournal $journal)
{
$type = strtolower($journal->transactionType->type);
$search = strtolower($this->trigger->trigger_value);
if ($type == $search) {
Log::debug('Journal is of type "' . $type . '" which matches with "' . $search . '". Return true');
return true;
}
Log::debug('Journal is of type "' . $type . '" which does not match with "' . $search . '". Return false');
return false;
}
}

View File

@@ -12,7 +12,6 @@ namespace FireflyIII\Rules\Triggers;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\RuleTrigger;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\Domain;
/**
@@ -27,17 +26,16 @@ class TriggerFactory
/**
* Returns the trigger for the given type and journal
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*
* @return TriggerInterface
*/
public static function getTrigger(RuleTrigger $trigger, TransactionJournal $journal): TriggerInterface
public static function getTrigger(RuleTrigger $trigger): TriggerInterface
{
$triggerType = $trigger->trigger_type;
$class = self::getTriggerClass($triggerType);
return new $class($trigger, $journal);
return new $class($trigger);
}
/**
@@ -45,7 +43,8 @@ class TriggerFactory
*
* @param string $triggerType
*
* @return TriggerInterface
* @return TriggerInterface|string
* @throws FireflyException
*/
public static function getTriggerClass(string $triggerType): string
{

View File

@@ -23,10 +23,9 @@ interface TriggerInterface
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal);
public function __construct(RuleTrigger $trigger);
/**
* A trigger is said to "match anything", or match any given transaction,
@@ -47,7 +46,9 @@ interface TriggerInterface
public static function willMatchEverything($value = null);
/**
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered();
public function triggered(TransactionJournal $journal);
}

View File

@@ -21,21 +21,20 @@ use Log;
*/
class UserAction implements TriggerInterface
{
/** @var TransactionJournal */
protected $journal;
/** @var RuleTrigger */
protected $trigger;
/**
* TriggerInterface constructor.
*
* @param RuleTrigger $trigger
* @param TransactionJournal $journal
* @param RuleTrigger $trigger
*/
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
public function __construct(RuleTrigger $trigger)
{
$this->trigger = $trigger;
$this->journal = $journal;
}
@@ -63,9 +62,11 @@ 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.
*
* @param TransactionJournal $journal
*
* @return bool
*/
public function triggered()
public function triggered(TransactionJournal $journal)
{
Log::debug('user_action always returns true.');