mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-19 16:10:00 +00:00
Code clean up.
This commit is contained in:
@@ -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\Triggers;
|
||||
@@ -30,20 +29,18 @@ use FireflyIII\Models\TransactionJournal;
|
||||
* This class will be magical!
|
||||
*
|
||||
* Class AbstractTrigger
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
*/
|
||||
class AbstractTrigger
|
||||
{
|
||||
/** @var bool */
|
||||
/** @var bool */
|
||||
public $stopProcessing;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $checkValue;
|
||||
/** @var TransactionJournal */
|
||||
/** @var TransactionJournal */
|
||||
protected $journal;
|
||||
/** @var RuleTrigger */
|
||||
protected $trigger;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $triggerValue;
|
||||
|
||||
/**
|
||||
@@ -106,6 +103,7 @@ class AbstractTrigger
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return RuleTrigger
|
||||
*/
|
||||
public function getTrigger(): RuleTrigger
|
||||
@@ -115,6 +113,7 @@ class AbstractTrigger
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTriggerValue(): string
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AmountExactly
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class AmountExactly.
|
||||
*/
|
||||
final class AmountExactly extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,7 +48,7 @@ final class AmountExactly extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
Log::error(sprintf('Cannot use %s with a null value.', self::class));
|
||||
@@ -70,7 +66,7 @@ final class AmountExactly extends AbstractTrigger implements TriggerInterface
|
||||
$amount = $journal->destination_amount ?? $journal->amountPositive();
|
||||
$compare = $this->triggerValue;
|
||||
$result = bccomp($amount, $compare);
|
||||
if ($result === 0) {
|
||||
if (0 === $result) {
|
||||
Log::debug(sprintf('RuleTrigger AmountExactly for journal #%d: %d matches %d exactly, so return true', $journal->id, $amount, $compare));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AmountLess
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class AmountLess.
|
||||
*/
|
||||
final class AmountLess extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,7 +48,7 @@ final class AmountLess extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
Log::error(sprintf('Cannot use %s with a null value.', self::class));
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AmountMore
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class AmountMore.
|
||||
*/
|
||||
final class AmountMore extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,9 +48,9 @@ final class AmountMore extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = bccomp('0', strval($value)) === 0;
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = 0 === bccomp('0', strval($value));
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with a value equal to 0.', self::class));
|
||||
}
|
||||
|
||||
@@ -76,7 +72,7 @@ final class AmountMore extends AbstractTrigger implements TriggerInterface
|
||||
$amount = $journal->destination_amount ?? $journal->amountPositive();
|
||||
$compare = $this->triggerValue;
|
||||
$result = bccomp($amount, $compare);
|
||||
if ($result === 1) {
|
||||
if (1 === $result) {
|
||||
Log::debug(sprintf('RuleTrigger AmountMore for journal #%d: %d is more than %d, so return true', $journal->id, $amount, $compare));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class BudgetIs
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class BudgetIs.
|
||||
*/
|
||||
final class BudgetIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,7 +49,7 @@ final class BudgetIs extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
Log::error(sprintf('Cannot use %s with a null value.', self::class));
|
||||
@@ -69,7 +65,7 @@ final class BudgetIs extends AbstractTrigger implements TriggerInterface
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$budget = $journal->budgets()->first();
|
||||
if (!is_null($budget)) {
|
||||
if (null !== $budget) {
|
||||
$name = strtolower($budget->name);
|
||||
// match on journal:
|
||||
if ($name === strtolower($this->triggerValue)) {
|
||||
@@ -79,12 +75,12 @@ final class BudgetIs extends AbstractTrigger implements TriggerInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($budget)) {
|
||||
if (null === $budget) {
|
||||
// perhaps transactions have this budget?
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
$budget = $transaction->budgets()->first();
|
||||
if (!is_null($budget)) {
|
||||
if (null !== $budget) {
|
||||
$name = strtolower($budget->name);
|
||||
if ($name === strtolower($this->triggerValue)) {
|
||||
Log::debug(
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class CategoryIs
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class CategoryIs.
|
||||
*/
|
||||
final class CategoryIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,7 +49,7 @@ final class CategoryIs extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
Log::error(sprintf('Cannot use %s with a null value.', self::class));
|
||||
@@ -69,7 +65,7 @@ final class CategoryIs extends AbstractTrigger implements TriggerInterface
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$category = $journal->categories()->first();
|
||||
if (!is_null($category)) {
|
||||
if (null !== $category) {
|
||||
$name = strtolower($category->name);
|
||||
// match on journal:
|
||||
if ($name === strtolower($this->triggerValue)) {
|
||||
@@ -79,12 +75,12 @@ final class CategoryIs extends AbstractTrigger implements TriggerInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($category)) {
|
||||
if (null === $category) {
|
||||
// perhaps transactions have this category?
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
$category = $transaction->categories()->first();
|
||||
if (!is_null($category)) {
|
||||
if (null !== $category) {
|
||||
$name = strtolower($category->name);
|
||||
if ($name === strtolower($this->triggerValue)) {
|
||||
Log::debug(
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DescriptionContains
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class DescriptionContains.
|
||||
*/
|
||||
final class DescriptionContains extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,9 +48,9 @@ final class DescriptionContains extends AbstractTrigger implements TriggerInterf
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -76,7 +72,7 @@ final class DescriptionContains extends AbstractTrigger implements TriggerInterf
|
||||
$search = strtolower($this->triggerValue);
|
||||
$source = strtolower($journal->description ?? '');
|
||||
$strpos = stripos($source, $search);
|
||||
if (!($strpos === false)) {
|
||||
if (!(false === $strpos)) {
|
||||
Log::debug(sprintf('RuleTrigger DescriptionContains for journal #%d: "%s" contains "%s", return true.', $journal->id, $source, $search));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DescriptionEnds
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class DescriptionEnds.
|
||||
*/
|
||||
final class DescriptionEnds extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,9 +48,9 @@ final class DescriptionEnds extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DescriptionIs
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class DescriptionIs.
|
||||
*/
|
||||
final class DescriptionIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,7 +48,7 @@ final class DescriptionIs extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DescriptionStarts
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class DescriptionStarts.
|
||||
*/
|
||||
final class DescriptionStarts extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,9 +48,9 @@ final class DescriptionStarts extends AbstractTrigger implements TriggerInterfac
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FromAccountContains
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class FromAccountContains.
|
||||
*/
|
||||
final class FromAccountContains extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -83,7 +79,7 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
|
||||
$search = strtolower($this->triggerValue);
|
||||
$strpos = strpos($fromAccountName, $search);
|
||||
|
||||
if (!($strpos === false)) {
|
||||
if (!(false === $strpos)) {
|
||||
Log::debug(sprintf('RuleTrigger FromAccountContains for journal #%d: "%s" contains "%s", return true.', $journal->id, $fromAccountName, $search));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FromAccountEnds
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class FromAccountEnds.
|
||||
*/
|
||||
final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -92,7 +88,6 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$part = substr($name, $searchLength * -1);
|
||||
|
||||
if ($part === $search) {
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FromAccountIs
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class FromAccountIs.
|
||||
*/
|
||||
final class FromAccountIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FromAccountStarts
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class FromAccountStarts.
|
||||
*/
|
||||
final class FromAccountStarts extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class HasAnyBudget
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class HasAnyBudget.
|
||||
*/
|
||||
final class HasAnyBudget extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class HasAnyCategory
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class HasAnyCategory.
|
||||
*/
|
||||
final class HasAnyCategory extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class HasAnyTag
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class HasAnyTag.
|
||||
*/
|
||||
final class HasAnyTag extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,7 +27,6 @@ use Log;
|
||||
|
||||
class HasAttachment extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class HasNoBudget
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class HasNoBudget.
|
||||
*/
|
||||
final class HasNoBudget extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -70,7 +66,7 @@ final class HasNoBudget extends AbstractTrigger implements TriggerInterface
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
$count += $transaction->budgets()->count();
|
||||
}
|
||||
if ($count === 0) {
|
||||
if (0 === $count) {
|
||||
Log::debug(sprintf('RuleTrigger HasNoBudget for journal #%d: count is %d, return true.', $journal->id, $count));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class HasNoCategory
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class HasNoCategory.
|
||||
*/
|
||||
final class HasNoCategory extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -71,7 +67,7 @@ final class HasNoCategory extends AbstractTrigger implements TriggerInterface
|
||||
$count += $transaction->categories()->count();
|
||||
}
|
||||
|
||||
if ($count === 0) {
|
||||
if (0 === $count) {
|
||||
Log::debug(sprintf('RuleTrigger HasNoCategory for journal #%d: count is %d, return true.', $journal->id, $count));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class HasNoTag
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class HasNoTag.
|
||||
*/
|
||||
final class HasNoTag extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -63,7 +59,7 @@ final class HasNoTag extends AbstractTrigger implements TriggerInterface
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$count = $journal->tags()->count();
|
||||
if ($count === 0) {
|
||||
if (0 === $count) {
|
||||
Log::debug(sprintf('RuleTrigger HasNoTag for journal #%d: count is %d, return true.', $journal->id, $count));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class NotesAny
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class NotesAny.
|
||||
*/
|
||||
final class NotesAny extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -66,7 +62,7 @@ final class NotesAny extends AbstractTrigger implements TriggerInterface
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
$text = '';
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$text = $note->text;
|
||||
}
|
||||
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class NotesAre
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class NotesAre.
|
||||
*/
|
||||
final class NotesAre extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,7 +49,7 @@ final class NotesAre extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,7 +68,7 @@ final class NotesAre extends AbstractTrigger implements TriggerInterface
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
$text = '';
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$text = strtolower($note->text);
|
||||
}
|
||||
$search = strtolower($this->triggerValue);
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class NotesContain
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class NotesContain.
|
||||
*/
|
||||
final class NotesContain extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class NotesContain extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -76,7 +72,7 @@ final class NotesContain extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
$search = trim(strtolower($this->triggerValue));
|
||||
|
||||
if (strlen($search) === 0) {
|
||||
if (0 === strlen($search)) {
|
||||
Log::debug(sprintf('RuleTrigger NotesContain for journal #%d: "%s" is empty, return false.', $journal->id, $search));
|
||||
|
||||
return false;
|
||||
@@ -85,13 +81,12 @@ final class NotesContain extends AbstractTrigger implements TriggerInterface
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
$text = '';
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$text = strtolower($note->text);
|
||||
}
|
||||
|
||||
|
||||
$strpos = strpos($text, $search);
|
||||
if (!($strpos === false)) {
|
||||
if (!(false === $strpos)) {
|
||||
Log::debug(sprintf('RuleTrigger NotesContain for journal #%d: "%s" contains "%s", return true.', $journal->id, $text, $search));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class NotesEmpty
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class NotesEmpty.
|
||||
*/
|
||||
final class NotesEmpty extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -66,11 +62,11 @@ final class NotesEmpty extends AbstractTrigger implements TriggerInterface
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
$text = '';
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$text = $note->text;
|
||||
}
|
||||
|
||||
if (strlen($text) === 0) {
|
||||
if (0 === strlen($text)) {
|
||||
Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen is 0, return true.', $journal->id));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class NotesEnd
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class NotesEnd.
|
||||
*/
|
||||
final class NotesEnd extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class NotesEnd extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -77,7 +73,7 @@ final class NotesEnd extends AbstractTrigger implements TriggerInterface
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
$text = '';
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$text = strtolower($note->text);
|
||||
}
|
||||
$notesLength = strlen($text);
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class NotesStart
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class NotesStart.
|
||||
*/
|
||||
final class NotesStart extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class NotesStart extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -77,7 +73,7 @@ final class NotesStart extends AbstractTrigger implements TriggerInterface
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
$text = '';
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$text = strtolower($note->text);
|
||||
}
|
||||
$search = strtolower($this->triggerValue);
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TagIs
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class TagIs.
|
||||
*/
|
||||
final class TagIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,7 +49,7 @@ final class TagIs extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
Log::error(sprintf('Cannot use %s with a null value.', self::class));
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ToAccountContains
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class ToAccountContains.
|
||||
*/
|
||||
final class ToAccountContains extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -83,7 +79,7 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac
|
||||
$search = strtolower($this->triggerValue);
|
||||
$strpos = strpos($toAccountName, $search);
|
||||
|
||||
if (!($strpos === false)) {
|
||||
if (!(false === $strpos)) {
|
||||
Log::debug(sprintf('RuleTrigger ToAccountContains for journal #%d: "%s" contains "%s", return true.', $journal->id, $toAccountName, $search));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ToAccountEnds
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class ToAccountEnds.
|
||||
*/
|
||||
final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -92,7 +88,6 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$part = substr($toAccountName, $searchLength * -1);
|
||||
|
||||
if ($part === $search) {
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ToAccountIs
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class ToAccountIs.
|
||||
*/
|
||||
final class ToAccountIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class ToAccountIs extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -28,13 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ToAccountStarts
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class ToAccountStarts.
|
||||
*/
|
||||
final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -53,9 +49,9 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$res = strval($value) === '';
|
||||
if ($res === true) {
|
||||
if (null !== $value) {
|
||||
$res = '' === strval($value);
|
||||
if (true === $res) {
|
||||
Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
|
||||
}
|
||||
|
||||
@@ -90,7 +86,6 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
|
||||
}
|
||||
Log::debug(sprintf('RuleTrigger ToAccountStarts for journal #%d: "%s" does not start with "%s", return false.', $journal->id, $toAccountName, $search));
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionType
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class TransactionType.
|
||||
*/
|
||||
final class TransactionType extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
@@ -52,7 +48,7 @@ final class TransactionType extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public static function willMatchEverything($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
return false;
|
||||
}
|
||||
Log::error(sprintf('Cannot use %s with a null value.', self::class));
|
||||
@@ -67,7 +63,7 @@ final class TransactionType extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$type = !is_null($journal->transaction_type_type) ? $journal->transaction_type_type : strtolower($journal->transactionType->type);
|
||||
$type = null !== $journal->transaction_type_type ? $journal->transaction_type_type : strtolower($journal->transactionType->type);
|
||||
$search = strtolower($this->triggerValue);
|
||||
|
||||
if ($type === $search) {
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -26,13 +25,10 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
* Interface TriggerInterface
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Interface TriggerInterface.
|
||||
*/
|
||||
interface TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
|
||||
@@ -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\Triggers;
|
||||
@@ -27,13 +26,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class UserAction
|
||||
*
|
||||
* @package FireflyIII\TransactionRules\Triggers
|
||||
* Class UserAction.
|
||||
*/
|
||||
final class UserAction extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* A trigger is said to "match anything", or match any given transaction,
|
||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||
|
||||
Reference in New Issue
Block a user