mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 05:06:37 +00:00
Some code cleanup courtesy of PHPStorm.
This commit is contained in:
@@ -72,7 +72,7 @@ class Processor
|
||||
$foundTriggers = 0;
|
||||
$hitTriggers = 0;
|
||||
/** @var RuleTrigger $trigger */
|
||||
foreach ($this->rule->ruleTriggers()->orderBy('order', 'ASC')->get() as $index => $trigger) {
|
||||
foreach ($this->rule->ruleTriggers()->orderBy('order', 'ASC')->get() as $trigger) {
|
||||
$foundTriggers++;
|
||||
$type = $trigger->trigger_type;
|
||||
|
||||
@@ -110,7 +110,7 @@ class Processor
|
||||
* @var int $index
|
||||
* @var RuleAction $action
|
||||
*/
|
||||
foreach ($this->rule->ruleActions()->orderBy('order', 'ASC')->get() as $index => $action) {
|
||||
foreach ($this->rule->ruleActions()->orderBy('order', 'ASC')->get() as $action) {
|
||||
$type = $action->action_type;
|
||||
$class = $this->actionTypes[$type];
|
||||
Log::debug('Action #' . $action->id . ' for rule #' . $action->rule_id . ' (' . $type . ')');
|
||||
|
||||
@@ -44,29 +44,29 @@ class FromAccountEnds implements TriggerInterface
|
||||
*/
|
||||
public function triggered()
|
||||
{
|
||||
$fromAccountName = strtolower($this->journal->source_account->name);
|
||||
$fromAccountNameLength = strlen($fromAccountName);
|
||||
$search = strtolower($this->trigger->trigger_value);
|
||||
$searchLength = strlen($search);
|
||||
$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 > $fromAccountNameLength) {
|
||||
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $fromAccountName . '" (' . $fromAccountNameLength . '). ');
|
||||
$search = substr($search, ($fromAccountNameLength * -1));
|
||||
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($fromAccountName, $searchLength * -1);
|
||||
$part = substr($name, $searchLength * -1);
|
||||
|
||||
if ($part == $search) {
|
||||
Log::debug('"' . $fromAccountName . '" ends with "' . $search . '". Return true.');
|
||||
Log::debug('"' . $name . '" ends with "' . $search . '". Return true.');
|
||||
|
||||
return true;
|
||||
}
|
||||
Log::debug('"' . $fromAccountName . '" does not end with "' . $search . '". Return false.');
|
||||
Log::debug('"' . $name . '" does not end with "' . $search . '". Return false.');
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user