Code clean up.

This commit is contained in:
James Cole
2017-11-15 12:25:49 +01:00
parent 57dcdfa0c4
commit ffca858b8d
476 changed files with 2055 additions and 4181 deletions

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\TransactionRules;
@@ -36,26 +35,23 @@ use Illuminate\Support\Collection;
use Log;
/**
* Class Processor
*
* @package FireflyIII\TransactionRules
* Class Processor.
*/
final class Processor
{
/** @var Collection */
/** @var Collection */
public $actions;
/** @var TransactionJournal */
/** @var TransactionJournal */
public $journal;
/** @var Rule */
/** @var Rule */
public $rule;
/** @var Collection */
public $triggers;
/** @var int */
protected $foundTriggers = 0;
private $foundTriggers = 0;
/**
* Processor constructor.
*
*/
private function __construct()
{
@@ -68,7 +64,6 @@ final class Processor
* and actions found in the given Rule.
*
* @param Rule $rule
*
* @param bool $includeActions
*
* @return Processor
@@ -128,7 +123,7 @@ final class Processor
{
$self = new self;
foreach ($triggers as $entry) {
$entry['value'] = is_null($entry['value']) ? '' : $entry['value'];
$entry['value'] = null === $entry['value'] ? '' : $entry['value'];
$trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stopProcessing']);
$self->triggers->push($trigger);
}
@@ -153,7 +148,6 @@ final class Processor
}
/**
*
* @return \FireflyIII\Models\Rule
*/
public function getRule(): Rule
@@ -185,7 +179,7 @@ final class Processor
Log::debug('Has more than zero actions.');
$this->actions();
}
if ($this->actions->count() === 0) {
if (0 === $this->actions->count()) {
Log::info('Rule has no actions!');
}
@@ -227,7 +221,7 @@ final class Processor
private function actions()
{
/**
* @var int $index
* @var int
* @var RuleAction $action
*/
foreach ($this->actions as $action) {
@@ -246,7 +240,7 @@ final class Processor
/**
* Method to check whether the current transaction would be triggered
* by the given list of triggers
* by the given list of triggers.
*
* @return bool
*/
@@ -258,12 +252,12 @@ final class Processor
Log::debug(sprintf('Found triggers starts at %d', $foundTriggers));
/** @var AbstractTrigger $trigger */
foreach ($this->triggers as $trigger) {
$foundTriggers++;
++$foundTriggers;
Log::debug(sprintf('Now checking trigger %s with value %s', get_class($trigger), $trigger->getTriggerValue()));
/** @var AbstractTrigger $trigger */
if ($trigger->triggered($this->journal)) {
Log::debug('Is a match!');
$hitTriggers++;
++$hitTriggers;
}
if ($trigger->stopProcessing) {
Log::debug('Stop processing this trigger and break.');