Some code cleanup courtesy of PHPStorm.

This commit is contained in:
James Cole
2016-01-15 17:53:54 +01:00
parent 820722f44e
commit f69be86c74
12 changed files with 39 additions and 93 deletions

View File

@@ -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 . ')');

View File

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