mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 07:38:29 +00:00
Reformat various code.
This commit is contained in:
@@ -86,84 +86,6 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
return $collection->unique();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function fire(): void
|
||||
{
|
||||
$this->resultCount = [];
|
||||
Log::debug('SearchRuleEngine::fire()!');
|
||||
|
||||
// if rules and no rule groups, file each rule separately.
|
||||
if (0 !== $this->rules->count()) {
|
||||
Log::debug(sprintf('SearchRuleEngine:: found %d rule(s) to fire.', $this->rules->count()));
|
||||
foreach ($this->rules as $rule) {
|
||||
$this->fireRule($rule);
|
||||
}
|
||||
Log::debug('SearchRuleEngine:: done processing all rules!');
|
||||
|
||||
return;
|
||||
}
|
||||
if (0 !== $this->groups->count()) {
|
||||
Log::debug(sprintf('SearchRuleEngine:: found %d rule group(s) to fire.', $this->groups->count()));
|
||||
// fire each group:
|
||||
/** @var RuleGroup $group */
|
||||
foreach ($this->groups as $group) {
|
||||
$this->fireGroup($group);
|
||||
}
|
||||
}
|
||||
Log::debug('SearchRuleEngine:: done processing all rules!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of changed transactions from the previous "fire" action.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getResults(): int
|
||||
{
|
||||
return count($this->resultCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setRuleGroups(Collection $ruleGroups): void
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
foreach ($ruleGroups as $group) {
|
||||
if ($group instanceof RuleGroup) {
|
||||
Log::debug(sprintf('Adding a rule group to the SearchRuleEngine: #%d ("%s")', $group->id, $group->title));
|
||||
$this->groups->push($group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setRules(Collection $rules): void
|
||||
{
|
||||
|
||||
Log::debug(__METHOD__);
|
||||
foreach ($rules as $rule) {
|
||||
if ($rule instanceof Rule) {
|
||||
Log::debug(sprintf('Adding a rule to the SearchRuleEngine: #%d ("%s")', $rule->id, $rule->title));
|
||||
$this->rules->push($rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->operators = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the transactions a strict rule will execute on.
|
||||
*
|
||||
@@ -266,7 +188,7 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
$journalId = 0;
|
||||
foreach ($array as $triggerName => $values) {
|
||||
if ('journal_id' === $triggerName && is_array($values) && 1 === count($values)) {
|
||||
$journalId = (int)trim(($values[0] ?? '"0"'), '"'); // follows format "123".
|
||||
$journalId = (int) trim(($values[0] ?? '"0"'), '"'); // follows format "123".
|
||||
Log::debug(sprintf('Found journal ID #%d', $journalId));
|
||||
}
|
||||
}
|
||||
@@ -365,6 +287,36 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
return $unique;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function fire(): void
|
||||
{
|
||||
$this->resultCount = [];
|
||||
Log::debug('SearchRuleEngine::fire()!');
|
||||
|
||||
// if rules and no rule groups, file each rule separately.
|
||||
if (0 !== $this->rules->count()) {
|
||||
Log::debug(sprintf('SearchRuleEngine:: found %d rule(s) to fire.', $this->rules->count()));
|
||||
foreach ($this->rules as $rule) {
|
||||
$this->fireRule($rule);
|
||||
}
|
||||
Log::debug('SearchRuleEngine:: done processing all rules!');
|
||||
|
||||
return;
|
||||
}
|
||||
if (0 !== $this->groups->count()) {
|
||||
Log::debug(sprintf('SearchRuleEngine:: found %d rule group(s) to fire.', $this->groups->count()));
|
||||
// fire each group:
|
||||
/** @var RuleGroup $group */
|
||||
foreach ($this->groups as $group) {
|
||||
$this->fireGroup($group);
|
||||
}
|
||||
}
|
||||
Log::debug('SearchRuleEngine:: done processing all rules!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the rule has been triggered.
|
||||
*
|
||||
@@ -460,7 +412,7 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
$actions = $rule->ruleActions()->get();
|
||||
/** @var RuleAction $ruleAction */
|
||||
foreach ($actions as $ruleAction) {
|
||||
if(false === $ruleAction->active) {
|
||||
if (false === $ruleAction->active) {
|
||||
continue;
|
||||
}
|
||||
$break = $this->processRuleAction($ruleAction, $transaction);
|
||||
@@ -553,4 +505,52 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
|
||||
return $all;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of changed transactions from the previous "fire" action.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getResults(): int
|
||||
{
|
||||
return count($this->resultCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setRuleGroups(Collection $ruleGroups): void
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
foreach ($ruleGroups as $group) {
|
||||
if ($group instanceof RuleGroup) {
|
||||
Log::debug(sprintf('Adding a rule group to the SearchRuleEngine: #%d ("%s")', $group->id, $group->title));
|
||||
$this->groups->push($group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setRules(Collection $rules): void
|
||||
{
|
||||
|
||||
Log::debug(__METHOD__);
|
||||
foreach ($rules as $rule) {
|
||||
if ($rule instanceof Rule) {
|
||||
Log::debug(sprintf('Adding a rule to the SearchRuleEngine: #%d ("%s")', $rule->id, $rule->title));
|
||||
$this->rules->push($rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->operators = [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user