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

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