Code cleanup

This commit is contained in:
James Cole 2019-08-17 10:47:29 +02:00
parent 23479790fe
commit c2296c3ad5
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
95 changed files with 463 additions and 507 deletions

View File

@ -33,9 +33,9 @@ class Amount implements ConverterInterface
* Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. * Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
* - Jamie Zawinski. * - Jamie Zawinski.
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
* @SuppressWarnings(PHPMD.NPathComplexity) *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @param $value * @param $value
* *
* @return string * @return string

View File

@ -46,7 +46,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
* if stage is not "new", then album must be 'station to station' * if stage is not "new", then album must be 'station to station'
* *
* @return bool * @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function configurationComplete(): bool public function configurationComplete(): bool
{ {
@ -70,7 +70,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
* *
* @return MessageBag * @return MessageBag
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function configureJob(array $data): MessageBag public function configureJob(array $data): MessageBag
{ {
@ -128,7 +128,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
* *
* @return string * @return string
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getNextView(): string public function getNextView(): string
{ {

View File

@ -89,10 +89,10 @@ class FileJobConfiguration implements JobConfigurationInterface
/** /**
* Returns the view of the next step in the job configuration. * Returns the view of the next step in the job configuration.
* *
* @throws FireflyException
* @return string * @return string
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*@throws FireflyException
*/ */
public function getNextView(): string public function getNextView(): string
{ {
@ -132,7 +132,7 @@ class FileJobConfiguration implements JobConfigurationInterface
* @return FileConfigurationInterface * @return FileConfigurationInterface
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function getConfigurationObject(): FileConfigurationInterface private function getConfigurationObject(): FileConfigurationInterface
{ {

View File

@ -111,7 +111,7 @@ class SpectreJobConfiguration implements JobConfigurationInterface
* @return SpectreJobConfigurationInterface * @return SpectreJobConfigurationInterface
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function getHandler(): SpectreJobConfigurationInterface private function getHandler(): SpectreJobConfigurationInterface
{ {

View File

@ -109,7 +109,7 @@ class YnabJobConfiguration implements JobConfigurationInterface
* @return YnabJobConfigurationInterface * @return YnabJobConfigurationInterface
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function getHandler(): YnabJobConfigurationInterface private function getHandler(): YnabJobConfigurationInterface
{ {

View File

@ -52,8 +52,8 @@ class FakeRoutine implements RoutineInterface
* @return void * @return void
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function run(): void public function run(): void
{ {

View File

@ -49,8 +49,8 @@ class SpectreRoutine implements RoutineInterface
* *
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function run(): void public function run(): void
{ {

View File

@ -64,7 +64,7 @@ class AbnAmroDescription implements SpecificInterface
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function run(array $row): array public function run(array $row): array
{ {
@ -132,8 +132,8 @@ class AbnAmroDescription implements SpecificInterface
* *
* @return bool true if the description is SEPA format, false otherwise * @return bool true if the description is SEPA format, false otherwise
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function parseSepaDescription(): bool protected function parseSepaDescription(): bool
{ {
@ -189,8 +189,8 @@ class AbnAmroDescription implements SpecificInterface
* *
* @return bool true if the description is TRTP format, false otherwise * @return bool true if the description is TRTP format, false otherwise
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function parseTRTPDescription(): bool protected function parseTRTPDescription(): bool
{ {

View File

@ -61,7 +61,7 @@ class Belfius implements SpecificInterface
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function run(array $row): array public function run(array $row): array
{ {

View File

@ -59,7 +59,7 @@ class IngBelgium implements SpecificInterface
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function run(array $row): array public function run(array $row): array
{ {

View File

@ -66,7 +66,7 @@ class IngDescription implements SpecificInterface
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function run(array $row): array public function run(array $row): array
{ {

View File

@ -59,7 +59,7 @@ class RabobankDescription implements SpecificInterface
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function run(array $row): array public function run(array $row): array
{ {

View File

@ -51,7 +51,7 @@ use Log;
* *
* Class ImportArrayStorage * Class ImportArrayStorage
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
*/ */
class ImportArrayStorage class ImportArrayStorage
{ {
@ -201,8 +201,8 @@ class ImportArrayStorage
* @return Collection * @return Collection
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
private function storeGroupArray(): Collection private function storeGroupArray(): Collection
{ {
@ -388,9 +388,9 @@ class ImportArrayStorage
* *
* @return bool * @return bool
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
* @SuppressWarnings(PHPMD.NPathComplexity) *
*/ */
private function transferExists(array $transaction): bool private function transferExists(array $transaction): bool
{ {

View File

@ -67,7 +67,7 @@ use Log;
/** /**
* Class CreateRecurringTransactions. * Class CreateRecurringTransactions.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
* *
*/ */
class CreateRecurringTransactions implements ShouldQueue class CreateRecurringTransactions implements ShouldQueue
@ -228,7 +228,7 @@ class CreateRecurringTransactions implements ShouldQueue
* @param Carbon $date * @param Carbon $date
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
private function getTransactionData(Recurrence $recurrence, Carbon $date): array private function getTransactionData(Recurrence $recurrence, Carbon $date): array
{ {
@ -441,8 +441,8 @@ class CreateRecurringTransactions implements ShouldQueue
* @param Recurrence $recurrence * @param Recurrence $recurrence
* *
* @return bool * @return bool
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function validRecurrence(Recurrence $recurrence): bool private function validRecurrence(Recurrence $recurrence): bool
{ {

View File

@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels;
/** /**
* Class AccessTokenCreatedMail * Class AccessTokenCreatedMail
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class AccessTokenCreatedMail extends Mailable class AccessTokenCreatedMail extends Mailable

View File

@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels;
* Class AdminTestMail. * Class AdminTestMail.
* *
* Sends a test mail to administrators. * Sends a test mail to administrators.
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class AdminTestMail extends Mailable class AdminTestMail extends Mailable

View File

@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels;
* Class ConfirmEmailChangeMail * Class ConfirmEmailChangeMail
* *
* Sends message to new address to confirm change. * Sends message to new address to confirm change.
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class ConfirmEmailChangeMail extends Mailable class ConfirmEmailChangeMail extends Mailable

View File

@ -31,6 +31,7 @@ use Laravel\Passport\Client;
/** /**
* Class OAuthTokenCreatedMail * Class OAuthTokenCreatedMail
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class OAuthTokenCreatedMail extends Mailable class OAuthTokenCreatedMail extends Mailable

View File

@ -31,6 +31,7 @@ use Illuminate\Queue\SerializesModels;
* Sends newly registered user an email message. * Sends newly registered user an email message.
* *
* Class RegisteredUser * Class RegisteredUser
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class RegisteredUser extends Mailable class RegisteredUser extends Mailable

View File

@ -31,6 +31,7 @@ use Illuminate\Support\Collection;
* Class ReportNewJournalsMail. * Class ReportNewJournalsMail.
* *
* Sends a list of newly created journals to the user. * Sends a list of newly created journals to the user.
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class ReportNewJournalsMail extends Mailable class ReportNewJournalsMail extends Mailable

View File

@ -30,6 +30,7 @@ use Illuminate\Queue\SerializesModels;
/** /**
* Sends user link for new password. * Sends user link for new password.
* Class RequestedNewPassword * Class RequestedNewPassword
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class RequestedNewPassword extends Mailable class RequestedNewPassword extends Mailable

View File

@ -28,6 +28,7 @@ use Illuminate\Queue\SerializesModels;
/** /**
* Class UndoEmailChangeMail * Class UndoEmailChangeMail
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class UndoEmailChangeMail extends Mailable class UndoEmailChangeMail extends Mailable

View File

@ -23,13 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Models; namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class Transaction. * Class Transaction.
@ -159,8 +157,6 @@ class Transaction extends Model
/** /**
* Check if a table is joined. * Check if a table is joined.
* *
*
*
* @param Builder $query * @param Builder $query
* @param string $table * @param string $table
* *

View File

@ -112,7 +112,7 @@ class EventServiceProvider extends ServiceProvider
} }
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function registerCreateEvents(): void protected function registerCreateEvents(): void
{ {

View File

@ -53,8 +53,8 @@ use FireflyIII\Services\IP\IPRetrievalInterface;
use FireflyIII\Services\Password\PwndVerifierV3; use FireflyIII\Services\Password\PwndVerifierV3;
use FireflyIII\Services\Password\Verifier; use FireflyIII\Services\Password\Verifier;
use FireflyIII\Support\Amount; use FireflyIII\Support\Amount;
use FireflyIII\Support\FireflyConfig;
use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\ExpandedForm;
use FireflyIII\Support\FireflyConfig;
use FireflyIII\Support\Form\AccountForm; use FireflyIII\Support\Form\AccountForm;
use FireflyIII\Support\Form\CurrencyForm; use FireflyIII\Support\Form\CurrencyForm;
use FireflyIII\Support\Form\PiggyBankForm; use FireflyIII\Support\Form\PiggyBankForm;
@ -63,9 +63,9 @@ use FireflyIII\Support\Navigation;
use FireflyIII\Support\Preferences; use FireflyIII\Support\Preferences;
use FireflyIII\Support\Steam; use FireflyIII\Support\Steam;
use FireflyIII\Support\Twig\AmountFormat; use FireflyIII\Support\Twig\AmountFormat;
use FireflyIII\Support\Twig\TransactionGroupTwig;
use FireflyIII\Support\Twig\General; use FireflyIII\Support\Twig\General;
use FireflyIII\Support\Twig\Rule; use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\TransactionGroupTwig;
use FireflyIII\Support\Twig\Translation; use FireflyIII\Support\Twig\Translation;
use FireflyIII\Validation\FireflyValidator; use FireflyIII\Validation\FireflyValidator;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
@ -80,7 +80,7 @@ use Validator;
* Class FireflyServiceProvider. * Class FireflyServiceProvider.
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
*/ */
class FireflyServiceProvider extends ServiceProvider class FireflyServiceProvider extends ServiceProvider
{ {
@ -108,7 +108,7 @@ class FireflyServiceProvider extends ServiceProvider
/** /**
* Register stuff. * Register stuff.
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function register(): void public function register(): void
{ {

View File

@ -40,7 +40,7 @@ use Log;
/** /**
* Class AccountRepository. * Class AccountRepository.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
*/ */
class AccountRepository implements AccountRepositoryInterface class AccountRepository implements AccountRepositoryInterface
{ {

View File

@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Attachment; namespace FireflyIII\Repositories\Attachment;
use Carbon\Carbon;
use Crypt; use Crypt;
use Exception; use Exception;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@ -38,7 +37,7 @@ use Log;
/** /**
* Class AttachmentRepository. * Class AttachmentRepository.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
*/ */
class AttachmentRepository implements AttachmentRepositoryInterface class AttachmentRepository implements AttachmentRepositoryInterface
{ {

View File

@ -41,7 +41,7 @@ use Log;
/** /**
* Class BillRepository. * Class BillRepository.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
*/ */
class BillRepository implements BillRepositoryInterface class BillRepository implements BillRepositoryInterface
{ {

View File

@ -46,9 +46,9 @@ use Navigation;
/** /**
* Class BudgetRepository. * Class BudgetRepository.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) *
*/ */
class BudgetRepository implements BudgetRepositoryInterface class BudgetRepository implements BudgetRepositoryInterface
{ {
@ -105,7 +105,7 @@ class BudgetRepository implements BudgetRepositoryInterface
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array
{ {
@ -173,8 +173,8 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param Carbon $end * @param Carbon $end
* *
* @return Collection * @return Collection
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function getBudgetLimits(Budget $budget, Carbon $start = null, Carbon $end = null): Collection public function getBudgetLimits(Budget $budget, Carbon $start = null, Carbon $end = null): Collection
{ {
@ -335,8 +335,8 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param Budget $budget * @param Budget $budget
* *
* @return Carbon * @return Carbon
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function firstUseDate(Budget $budget): ?Carbon public function firstUseDate(Budget $budget): ?Carbon
{ {
@ -377,8 +377,8 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param Carbon $end * @param Carbon $end
* *
* @return Collection * @return Collection
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function getAllBudgetLimits(Carbon $start = null, Carbon $end = null): Collection public function getAllBudgetLimits(Carbon $start = null, Carbon $end = null): Collection
{ {
@ -870,7 +870,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/** /**
* @return bool * @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 5. * // it's 5.
*/ */
public function cleanupBudgets(): bool public function cleanupBudgets(): bool
{ {
@ -992,8 +992,8 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param string $amount * @param string $amount
* *
* @return BudgetLimit|null * @return BudgetLimit|null
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit
{ {

View File

@ -37,9 +37,9 @@ use Navigation;
/** /**
* Class CategoryRepository. * Class CategoryRepository.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) *
*/ */
class CategoryRepository implements CategoryRepositoryInterface class CategoryRepository implements CategoryRepositoryInterface
{ {
@ -323,7 +323,7 @@ class CategoryRepository implements CategoryRepositoryInterface
* @param Category $category * @param Category $category
* *
* @return Carbon|null * @return Carbon|null
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function firstUseDate(Category $category): ?Carbon public function firstUseDate(Category $category): ?Carbon
{ {
@ -365,7 +365,7 @@ class CategoryRepository implements CategoryRepositoryInterface
* *
* @return Carbon|null * @return Carbon|null
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function lastUseDate(Category $category, Collection $accounts): ?Carbon public function lastUseDate(Category $category, Collection $accounts): ?Carbon
{ {

View File

@ -38,7 +38,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
/** /**
* Class ImportJobRepository. * Class ImportJobRepository.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) *
*/ */
class ImportJobRepository implements ImportJobRepositoryInterface class ImportJobRepository implements ImportJobRepositoryInterface
{ {

View File

@ -34,7 +34,7 @@ use Log;
/** /**
* Class LinkTypeRepository. * Class LinkTypeRepository.
* *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
*/ */
class LinkTypeRepository implements LinkTypeRepositoryInterface class LinkTypeRepository implements LinkTypeRepositoryInterface
{ {
@ -252,7 +252,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
* @param TransactionJournal $outward * @param TransactionJournal $outward
* *
* @return TransactionJournalLink|null * @return TransactionJournalLink|null
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink
{ {
@ -347,7 +347,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
* @param TransactionJournalLink $link * @param TransactionJournalLink $link
* @param string $text * @param string $text
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @throws \Exception * @throws \Exception
*/ */
private function setNoteText(TransactionJournalLink $link, string $text): void private function setNoteText(TransactionJournalLink $link, string $text): void

View File

@ -37,8 +37,8 @@ use Log;
/** /**
* Class PiggyBankRepository. * Class PiggyBankRepository.
* *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) *
*/ */
class PiggyBankRepository implements PiggyBankRepositoryInterface class PiggyBankRepository implements PiggyBankRepositoryInterface
{ {
@ -293,7 +293,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string
{ {
@ -406,7 +406,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string
{ {

View File

@ -234,9 +234,8 @@ class RecurringRepository implements RecurringRepositoryInterface
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
*
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getOccurrencesInRange(RecurrenceRepetition $repetition, Carbon $start, Carbon $end): array public function getOccurrencesInRange(RecurrenceRepetition $repetition, Carbon $start, Carbon $end): array
{ {
@ -366,7 +365,7 @@ class RecurringRepository implements RecurringRepositoryInterface
* @param int $count * @param int $count
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getXOccurrences(RecurrenceRepetition $repetition, Carbon $date, int $count): array public function getXOccurrences(RecurrenceRepetition $repetition, Carbon $date, int $count): array
{ {
@ -400,7 +399,7 @@ class RecurringRepository implements RecurringRepositoryInterface
* @param RecurrenceRepetition $repetition * @param RecurrenceRepetition $repetition
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function repetitionDescription(RecurrenceRepetition $repetition): string public function repetitionDescription(RecurrenceRepetition $repetition): string
{ {

View File

@ -34,7 +34,7 @@ use Log;
/** /**
* Class RuleRepository. * Class RuleRepository.
* *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
*/ */
class RuleRepository implements RuleRepositoryInterface class RuleRepository implements RuleRepositoryInterface
{ {

View File

@ -36,7 +36,7 @@ use Log;
/** /**
* Class TagRepository. * Class TagRepository.
* *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
*/ */
class TagRepository implements TagRepositoryInterface class TagRepository implements TagRepositoryInterface
{ {
@ -272,7 +272,7 @@ class TagRepository implements TagRepositoryInterface
* @param Carbon|null $end * @param Carbon|null $end
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array
{ {
@ -410,7 +410,7 @@ class TagRepository implements TagRepositoryInterface
* @param Collection $tags * @param Collection $tags
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function getMinAmount(Collection $tags): string private function getMinAmount(Collection $tags): string
{ {

View File

@ -32,7 +32,7 @@ use Log;
/** /**
* Class UserRepository. * Class UserRepository.
* *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
*/ */
class UserRepository implements UserRepositoryInterface class UserRepository implements UserRepositoryInterface
{ {

View File

@ -69,8 +69,8 @@ class BelongsUser implements Rule
* @return bool * @return bool
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public function passes($attribute, $value): bool public function passes($attribute, $value): bool
{ {
@ -110,7 +110,7 @@ class BelongsUser implements Rule
* *
* @return int * @return int
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function countField(string $class, string $field, string $value): int protected function countField(string $class, string $field, string $value): int
{ {

View File

@ -50,8 +50,6 @@ class IsAssetAccountId implements Rule
* @param mixed $value * @param mixed $value
* *
* @return bool * @return bool
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function passes($attribute, $value): bool public function passes($attribute, $value): bool
{ {

View File

@ -74,8 +74,6 @@ class IsValidAttachmentModel implements Rule
* @param mixed $value * @param mixed $value
* *
* @return bool * @return bool
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function passes($attribute, $value): bool public function passes($attribute, $value): bool
{ {

View File

@ -72,8 +72,8 @@ class UniqueIban implements Rule
* @param mixed $value * @param mixed $value
* *
* @return bool * @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.UnusedFormalParameter) *
*/ */
public function passes($attribute, $value): bool public function passes($attribute, $value): bool
{ {
@ -127,7 +127,7 @@ class UniqueIban implements Rule
/** /**
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function getMaxOccurrences(): array private function getMaxOccurrences(): array
{ {

View File

@ -52,7 +52,7 @@ class ValidJournals implements Rule
* @param mixed $value * @param mixed $value
* *
* @return bool * @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter) *
*/ */
public function passes($attribute, $value): bool public function passes($attribute, $value): bool
{ {

View File

@ -49,8 +49,8 @@ class ValidRecurrenceRepetitionType implements Rule
* @param mixed $value * @param mixed $value
* *
* @return bool * @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter) *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function passes($attribute, $value): bool public function passes($attribute, $value): bool
{ {

View File

@ -53,8 +53,8 @@ class ValidRecurrenceRepetitionValue implements Rule
* @param mixed $value * @param mixed $value
* *
* @return bool * @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter) *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function passes($attribute, $value): bool public function passes($attribute, $value): bool
{ {
@ -104,7 +104,7 @@ class ValidRecurrenceRepetitionValue implements Rule
* *
* @return bool * @return bool
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function validateNdom(string $value): bool private function validateNdom(string $value): bool
{ {

View File

@ -47,9 +47,9 @@ class ApiContext
* @param array $permittedIps * @param array $permittedIps
* @param string|null $proxyUrl * @param string|null $proxyUrl
* *
* @throws FireflyException
* @return BunqApiContext|FakeApiContext * @return BunqApiContext|FakeApiContext
* @SuppressWarnings(PHPMD.ExcessiveParameterList) *
*@throws FireflyException
*/ */
public function create(BunqEnumApiEnvironmentType $environmentType, string $apiKey, string $description, array $permittedIps, string $proxyUrl = null public function create(BunqEnumApiEnvironmentType $environmentType, string $apiKey, string $description, array $permittedIps, string $proxyUrl = null
) { ) {

View File

@ -48,7 +48,7 @@ class RecurrenceDestroyService
* Delete recurrence. * Delete recurrence.
* *
* @param Recurrence $recurrence * @param Recurrence $recurrence
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function destroy(Recurrence $recurrence): void public function destroy(Recurrence $recurrence): void
{ {

View File

@ -86,7 +86,7 @@ trait AccountServiceTrait
* *
* @param Account $account * @param Account $account
* @param array $data * @param array $data
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function updateMetaData(Account $account, array $data): void public function updateMetaData(Account $account, array $data): void
{ {

View File

@ -263,7 +263,7 @@ trait JournalServiceTrait
* *
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param array $tags * @param array $tags
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -34,7 +34,7 @@ class Holder extends SpectreObject
* Holder constructor. * Holder constructor.
* *
* @param array $data * @param array $data
* @SuppressWarnings(PHPMD.UnusedFormalParameter) *
*/ */
public function __construct(array $data) public function __construct(array $data)
{ {

View File

@ -175,7 +175,7 @@ class Transaction extends SpectreObject
* Get opposing account data. * Get opposing account data.
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getOpposingAccountData(): array public function getOpposingAccountData(): array
{ {

View File

@ -41,7 +41,7 @@ class ListAccountsRequest extends SpectreRequest
/** /**
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function call(): void public function call(): void
{ {

View File

@ -39,7 +39,7 @@ class ListCustomersRequest extends SpectreRequest
/** /**
* *
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function call(): void public function call(): void
{ {

View File

@ -43,7 +43,7 @@ class ListLoginsRequest extends SpectreRequest
/** /**
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function call(): void public function call(): void
{ {

View File

@ -41,7 +41,7 @@ class ListTransactionsRequest extends SpectreRequest
/** /**
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function call(): void public function call(): void
{ {

View File

@ -50,8 +50,6 @@ class Amount
* *
* @return string * @return string
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public static function getAmountJsConfig(bool $sepBySpace, int $signPosn, string $sign, bool $csPrecedes): string public static function getAmountJsConfig(bool $sepBySpace, int $signPosn, string $sign, bool $csPrecedes): string
{ {
@ -122,7 +120,7 @@ class Amount
* @param bool $coloured * @param bool $coloured
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = null): string public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = null): string
{ {
@ -164,7 +162,7 @@ class Amount
* @param bool $coloured * @param bool $coloured
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @noinspection MoreThanThreeArgumentsInspection * @noinspection MoreThanThreeArgumentsInspection
*/ */
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, bool $coloured = null): string public function formatFlat(string $symbol, int $decimalPlaces, string $amount, bool $coloured = null): string

View File

@ -40,7 +40,7 @@ class AccountList implements BinderInterface
* *
* @return Collection * @return Collection
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public static function routeBinder(string $value, Route $route): Collection public static function routeBinder(string $value, Route $route): Collection
{ {

View File

@ -39,7 +39,7 @@ class BudgetList implements BinderInterface
* *
* @return Collection * @return Collection
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public static function routeBinder(string $value, Route $route): Collection public static function routeBinder(string $value, Route $route): Collection
{ {

View File

@ -38,7 +38,7 @@ class CategoryList implements BinderInterface
* *
* @return Collection * @return Collection
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public static function routeBinder(string $value, Route $route): Collection public static function routeBinder(string $value, Route $route): Collection
{ {

View File

@ -27,7 +27,6 @@ use FireflyIII\Import\Prerequisites\PrerequisitesInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Routing\Route; use Illuminate\Routing\Route;
use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@ -37,8 +36,8 @@ class ImportProvider implements BinderInterface
{ {
/** /**
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
public static function getProviders(): array public static function getProviders(): array
{ {

View File

@ -23,32 +23,17 @@ declare(strict_types=1);
namespace FireflyIII\Support; namespace FireflyIII\Support;
use Amount as Amt; use Amount as Amt;
use Carbon\Carbon;
use Eloquent; use Eloquent;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Support\Form\FormSupport; use FireflyIII\Support\Form\FormSupport;
use Form;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
use Illuminate\Support\MessageBag;
use Log; use Log;
use RuntimeException;
use Throwable; use Throwable;
/** /**
* Class ExpandedForm. * Class ExpandedForm.
* *
* @SuppressWarnings(PHPMD.TooManyMethods) * @SuppressWarnings(PHPMD.TooManyMethods)
* @SuppressWarnings(PHPMD.TooManyPublicMethods) *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class ExpandedForm class ExpandedForm
@ -225,7 +210,7 @@ class ExpandedForm
* @param \Illuminate\Support\Collection $set * @param \Illuminate\Support\Collection $set
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function makeSelectListWithEmpty(Collection $set): array public function makeSelectListWithEmpty(Collection $set): array
{ {

View File

@ -117,7 +117,7 @@ class CurrencyForm
* @param array $options * @param array $options
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string
{ {
@ -168,7 +168,7 @@ class CurrencyForm
* @param array $options * @param array $options
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function currencyField(string $name, string $view, $value = null, array $options = null): string protected function currencyField(string $name, string $view, $value = null, array $options = null): string
{ {

View File

@ -79,8 +79,8 @@ trait AugumentData
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function earnedByCategory(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info protected function earnedByCategory(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info
{ {
@ -352,7 +352,7 @@ trait AugumentData
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function getExpensesForBudget(Collection $limits, Budget $budget, Carbon $start, Carbon $end): array // get data + augment with info protected function getExpensesForBudget(Collection $limits, Budget $budget, Carbon $start, Carbon $end): array // get data + augment with info
{ {
@ -397,7 +397,7 @@ trait AugumentData
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* *
*/ */
protected function spentInPeriodMulti(Budget $budget, Collection $limits): array // get data + augment with info protected function spentInPeriodMulti(Budget $budget, Collection $limits): array // get data + augment with info
@ -586,8 +586,8 @@ trait AugumentData
* @param Carbon $end * @param Carbon $end
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function spentByBudget(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info protected function spentByBudget(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info
{ {
@ -647,8 +647,8 @@ trait AugumentData
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function spentByCategory(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info protected function spentByCategory(Collection $assets, Collection $opposing, Carbon $start, Carbon $end): array // get data + augment with info
{ {

View File

@ -47,8 +47,8 @@ trait ChartGeneration
* *
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method. protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.
{ {

View File

@ -88,7 +88,7 @@ trait GetConfigurationData
* Get config for date range. * Get config for date range.
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function getDateRangeConfig(): array // get configuration + get preferences. protected function getDateRangeConfig(): array // get configuration + get preferences.
{ {
@ -177,7 +177,7 @@ trait GetConfigurationData
* @param string $specificPage * @param string $specificPage
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function getSpecificSteps(string $route, string $specificPage): array // get config values protected function getSpecificSteps(string $route, string $specificPage): array // get config values
{ {

View File

@ -28,7 +28,6 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -281,7 +280,7 @@ trait PeriodOverview
* @param Carbon $theDate * @param Carbon $theDate
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function getNoCategoryPeriodOverview(Carbon $theDate): array protected function getNoCategoryPeriodOverview(Carbon $theDate): array
{ {

View File

@ -83,7 +83,7 @@ trait RenderPartialViews
* *
* @return string * @return string
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function balanceAmount(array $attributes): string // generate view for report. protected function balanceAmount(array $attributes): string // generate view for report.
{ {

View File

@ -65,8 +65,8 @@ trait RequestInformation
* @param string $language * @param string $language
* *
* @return string * @return string
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function getHelpText(string $route, string $language): string // get from internet. protected function getHelpText(string $route, string $language): string // get from internet.
{ {
@ -213,7 +213,7 @@ trait RequestInformation
* @param Carbon $date * @param Carbon $date
* *
* @return bool * @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function notInSessionRange(Carbon $date): bool // Validate a preference protected function notInSessionRange(Carbon $date): bool // Validate a preference
{ {

View File

@ -109,8 +109,6 @@ trait TransactionCalculation
* @param Carbon $end * @param Carbon $end
* *
* @return array * @return array
*
*
*/ */
protected function getExpensesInCategories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): array protected function getExpensesInCategories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): array
{ {
@ -175,8 +173,6 @@ trait TransactionCalculation
* @param Carbon $end * @param Carbon $end
* *
* @return Collection * @return Collection
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/ */
protected function getIncomeForTags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): array protected function getIncomeForTags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): array
{ {

View File

@ -272,7 +272,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
* *
* @return array * @return array
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getValuesForMapping(Reader $reader, array $config, array $columnConfig): array public function getValuesForMapping(Reader $reader, array $config, array $columnConfig): array
{ {

View File

@ -58,7 +58,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
* @param array $config * @param array $config
* *
* @return MessageBag * @return MessageBag
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function configurationComplete(array $config): MessageBag public function configurationComplete(array $config): MessageBag
{ {

View File

@ -110,7 +110,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
* *
* @return array * @return array
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function getNextData(): array public function getNextData(): array
{ {

View File

@ -132,7 +132,7 @@ class ImportTransaction
* @param ColumnValue $columnValue * @param ColumnValue $columnValue
* *
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function addColumnValue(ColumnValue $columnValue): void public function addColumnValue(ColumnValue $columnValue): void
{ {

View File

@ -60,7 +60,7 @@ class AssetAccountMapper
* @param array $data * @param array $data
* *
* @return Account * @return Account
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function map(?int $accountId, array $data): Account public function map(?int $accountId, array $data): Account
{ {

View File

@ -81,7 +81,7 @@ class MappedValuesValidator
* *
* @return array * @return array
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function validate(array $mappings): array public function validate(array $mappings): array
{ {

View File

@ -45,7 +45,7 @@ class OpposingAccountMapper
* @param array $data * @param array $data
* *
* @return Account * @return Account
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function map(?int $accountId, string $amount, array $data): Account public function map(?int $accountId, string $amount, array $data): Account
{ {

View File

@ -108,7 +108,7 @@ class StageImportDataHandler
* @param LocalAccount $originalSource * @param LocalAccount $originalSource
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function convertToArray(array $transactions, SpectreAccount $spectreAccount, LocalAccount $originalSource): array private function convertToArray(array $transactions, SpectreAccount $spectreAccount, LocalAccount $originalSource): array
{ {

View File

@ -104,7 +104,7 @@ class Navigation
* *
* @return array * @return array
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
public function blockPeriods(\Carbon\Carbon $start, \Carbon\Carbon $end, string $range): array public function blockPeriods(\Carbon\Carbon $start, \Carbon\Carbon $end, string $range): array
{ {

View File

@ -70,7 +70,7 @@ trait CalculateRangeOccurrences
* @param string $moment * @param string $moment
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function getMonthlyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array protected function getMonthlyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array
{ {
@ -150,7 +150,7 @@ trait CalculateRangeOccurrences
* @param string $moment * @param string $moment
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function getWeeklyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array protected function getWeeklyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array
{ {
@ -194,7 +194,7 @@ trait CalculateRangeOccurrences
* @param string $moment * @param string $moment
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
protected function getYearlyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array protected function getYearlyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array
{ {

View File

@ -42,8 +42,8 @@ trait FiltersWeekends
* @param array $dates * @param array $dates
* *
* @return array * @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) *
*/ */
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
{ {

View File

@ -181,7 +181,7 @@ class Search implements SearchInterface
* @param GroupCollectorInterface $collector * @param GroupCollectorInterface $collector
* *
* @return GroupCollectorInterface * @return GroupCollectorInterface
* @SuppressWarnings(PHPMD.CyclomaticComplexity) *
*/ */
private function applyModifiers(GroupCollectorInterface $collector): GroupCollectorInterface private function applyModifiers(GroupCollectorInterface $collector): GroupCollectorInterface
{ {

View File

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions; namespace FireflyIII\TransactionRules\Actions;
use Exception;
use FireflyIII\Models\Note; use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
@ -47,7 +48,7 @@ class ClearNotes implements ActionInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
* @throws \Exception * @throws Exception
*/ */
public function act(TransactionJournal $journal): bool public function act(TransactionJournal $journal): bool
{ {

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions; namespace FireflyIII\TransactionRules\Actions;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\AccountFactory; use FireflyIII\Factory\AccountFactory;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
@ -57,7 +58,7 @@ class ConvertToDeposit implements ActionInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
public function act(TransactionJournal $journal): bool public function act(TransactionJournal $journal): bool
{ {
@ -121,7 +122,7 @@ class ConvertToDeposit implements ActionInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
private function convertTransfer(TransactionJournal $journal): bool private function convertTransfer(TransactionJournal $journal): bool
{ {
@ -163,7 +164,7 @@ class ConvertToDeposit implements ActionInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
private function convertWithdrawal(TransactionJournal $journal): bool private function convertWithdrawal(TransactionJournal $journal): bool
{ {

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions; namespace FireflyIII\TransactionRules\Actions;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\AccountFactory; use FireflyIII\Factory\AccountFactory;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
@ -58,7 +59,7 @@ class ConvertToWithdrawal implements ActionInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
public function act(TransactionJournal $journal): bool public function act(TransactionJournal $journal): bool
{ {
@ -122,7 +123,7 @@ class ConvertToWithdrawal implements ActionInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
private function convertDeposit(TransactionJournal $journal): bool private function convertDeposit(TransactionJournal $journal): bool
{ {
@ -175,7 +176,7 @@ class ConvertToWithdrawal implements ActionInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
private function convertTransfer(TransactionJournal $journal): bool private function convertTransfer(TransactionJournal $journal): bool
{ {

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions; namespace FireflyIII\TransactionRules\Actions;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Log; use Log;
@ -47,6 +46,7 @@ class RemoveTag implements ActionInterface
/** /**
* Remove tag X * Remove tag X
*
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
@ -55,7 +55,7 @@ class RemoveTag implements ActionInterface
{ {
// if tag does not exist, no need to continue: // if tag does not exist, no need to continue:
$name = $this->action->action_value; $name = $this->action->action_value;
$tag = $journal->user->tags()->where('tag', $name)->first(); $tag = $journal->user->tags()->where('tag', $name)->first();
if (null !== $tag) { if (null !== $tag) {
Log::debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal->id)); Log::debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal->id));

View File

@ -47,13 +47,14 @@ class SetBudget implements ActionInterface
/** /**
* Set budget. * Set budget.
*
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *
* @return bool * @return bool
*/ */
public function act(TransactionJournal $journal): bool public function act(TransactionJournal $journal): bool
{ {
$search = $this->action->action_value; $search = $this->action->action_value;
$budget = $journal->user->budgets()->where('name', $search)->first(); $budget = $journal->user->budgets()->where('name', $search)->first();
if (null === $budget) { if (null === $budget) {

View File

@ -24,7 +24,6 @@ namespace FireflyIII\TransactionRules\Actions;
use FireflyIII\Factory\CategoryFactory; use FireflyIII\Factory\CategoryFactory;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Log; use Log;

View File

@ -133,9 +133,9 @@ class SetDestinationAccount implements ActionInterface
if (null === $account) { if (null === $account) {
$data = [ $data = [
'name' => $this->action->action_value, 'name' => $this->action->action_value,
'account_type' => 'expense', 'account_type' => 'expense',
'account_type_id' => null, 'account_type_id' => null,
'virtual_balance' => 0, 'virtual_balance' => 0,
'active' => true, 'active' => true,
'iban' => null, 'iban' => null,
]; ];

View File

@ -137,9 +137,9 @@ class SetSourceAccount implements ActionInterface
// create new revenue account with this name: // create new revenue account with this name:
$data = [ $data = [
'name' => $this->action->action_value, 'name' => $this->action->action_value,
'account_type' => 'revenue', 'account_type' => 'revenue',
'account_type_id' => null, 'account_type_id' => null,
'virtual_balance' => 0, 'virtual_balance' => 0,
'active' => true, 'active' => true,
'iban' => null, 'iban' => null,
]; ];

View File

@ -45,19 +45,18 @@ class RuleEngine
public const TRIGGER_STORE = 1; public const TRIGGER_STORE = 1;
/** @var int */ /** @var int */
public const TRIGGER_UPDATE = 2; public const TRIGGER_UPDATE = 2;
/** @var bool */
private $allRules;
/** @var RuleGroupRepository */
private $ruleGroupRepository;
/** @var Collection */ /** @var Collection */
private $ruleGroups; private $ruleGroups;
/** @var array */ /** @var array */
private $rulesToApply; private $rulesToApply;
/** @var bool */
private $allRules;
/** @var User */
private $user;
/** @var RuleGroupRepository */
private $ruleGroupRepository;
/** @var int */ /** @var int */
private $triggerMode; private $triggerMode;
/** @var User */
private $user;
/** /**
* RuleEngine constructor. * RuleEngine constructor.
@ -72,94 +71,6 @@ class RuleEngine
$this->triggerMode = self::TRIGGER_STORE; $this->triggerMode = self::TRIGGER_STORE;
} }
/**
* @param int $triggerMode
*/
public function setTriggerMode(int $triggerMode): void
{
$this->triggerMode = $triggerMode;
}
/**
* @param bool $allRules
*/
public function setAllRules(bool $allRules): void
{
Log::debug('RuleEngine will apply ALL rules.');
$this->allRules = $allRules;
}
/**
* @param array $rulesToApply
*/
public function setRulesToApply(array $rulesToApply): void
{
Log::debug('RuleEngine will try rules', $rulesToApply);
$this->rulesToApply = $rulesToApply;
}
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
$this->ruleGroupRepository->setUser($user);
$this->ruleGroups = $this->ruleGroupRepository->getActiveGroups();
}
/**
* @param TransactionJournal $transactionJournal
*/
public function processTransactionJournal(TransactionJournal $transactionJournal): void
{
Log::debug(sprintf('Will process transaction journal #%d ("%s")', $transactionJournal->id, $transactionJournal->description));
/** @var RuleGroup $group */
foreach ($this->ruleGroups as $group) {
Log::debug(sprintf('Now at rule group #%d', $group->id));
$groupTriggered = false;
/** @var Rule $rule */
foreach ($group->rules as $rule) {
Log::debug(sprintf('Now at rule #%d from rule group #%d', $rule->id, $group->id));
$ruleTriggered = false;
// if in rule selection, or group in selection or all rules, it's included.
if ($this->includeRule($rule)) {
Log::debug(sprintf('Rule #%d is included.', $rule->id));
/** @var Processor $processor */
$processor = app(Processor::class);
$ruleTriggered = false;
try {
$processor->make($rule, true);
$ruleTriggered = $processor->handleTransactionJournal($transactionJournal);
} catch (FireflyException $e) {
Log::error($e->getMessage());
}
if ($ruleTriggered) {
Log::debug('The rule was triggered, so the group is as well!');
$groupTriggered = true;
}
}
if (!$this->includeRule($rule)) {
Log::debug(sprintf('Rule #%d is not included.', $rule->id));
}
// if the rule is triggered and stop processing is true, cancel the entire group.
if ($ruleTriggered && $rule->stop_processing) {
Log::info(sprintf('Break out group #%d because rule #%d was triggered.', $group->id, $rule->id));
break;
}
}
// if group is triggered and stop processing is true, cancel the whole thing.
if ($groupTriggered && $group->stop_processing) {
Log::info(sprintf('Break out ALL because group #%d was triggered.', $group->id));
break;
}
}
Log::debug('Done processing this transaction journal.');
}
/** /**
* @param array $journal * @param array $journal
*/ */
@ -212,8 +123,96 @@ class RuleEngine
Log::debug('Done processing this transaction journal.'); Log::debug('Done processing this transaction journal.');
} }
/**
* @param TransactionJournal $transactionJournal
*/
public function processTransactionJournal(TransactionJournal $transactionJournal): void
{
Log::debug(sprintf('Will process transaction journal #%d ("%s")', $transactionJournal->id, $transactionJournal->description));
/** @var RuleGroup $group */
foreach ($this->ruleGroups as $group) {
Log::debug(sprintf('Now at rule group #%d', $group->id));
$groupTriggered = false;
/** @var Rule $rule */
foreach ($group->rules as $rule) {
Log::debug(sprintf('Now at rule #%d from rule group #%d', $rule->id, $group->id));
$ruleTriggered = false;
// if in rule selection, or group in selection or all rules, it's included.
if ($this->includeRule($rule)) {
Log::debug(sprintf('Rule #%d is included.', $rule->id));
/** @var Processor $processor */
$processor = app(Processor::class);
$ruleTriggered = false;
try {
$processor->make($rule, true);
$ruleTriggered = $processor->handleTransactionJournal($transactionJournal);
} catch (FireflyException $e) {
Log::error($e->getMessage());
}
if ($ruleTriggered) {
Log::debug('The rule was triggered, so the group is as well!');
$groupTriggered = true;
}
}
if (!$this->includeRule($rule)) {
Log::debug(sprintf('Rule #%d is not included.', $rule->id));
}
// if the rule is triggered and stop processing is true, cancel the entire group.
if ($ruleTriggered && $rule->stop_processing) {
Log::info(sprintf('Break out group #%d because rule #%d was triggered.', $group->id, $rule->id));
break;
}
}
// if group is triggered and stop processing is true, cancel the whole thing.
if ($groupTriggered && $group->stop_processing) {
Log::info(sprintf('Break out ALL because group #%d was triggered.', $group->id));
break;
}
}
Log::debug('Done processing this transaction journal.');
}
/**
* @param bool $allRules
*/
public function setAllRules(bool $allRules): void
{
Log::debug('RuleEngine will apply ALL rules.');
$this->allRules = $allRules;
}
/**
* @param array $rulesToApply
*/
public function setRulesToApply(array $rulesToApply): void
{
Log::debug('RuleEngine will try rules', $rulesToApply);
$this->rulesToApply = $rulesToApply;
}
/**
* @param int $triggerMode
*/
public function setTriggerMode(int $triggerMode): void
{
$this->triggerMode = $triggerMode;
}
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
$this->ruleGroupRepository->setUser($user);
$this->ruleGroups = $this->ruleGroupRepository->getActiveGroups();
}
/** /**
* @param Rule $rule * @param Rule $rule
*
* @return bool * @return bool
*/ */
private function includeRule(Rule $rule): bool private function includeRule(Rule $rule): bool
@ -224,8 +223,8 @@ class RuleEngine
return false; return false;
} }
$validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode) || $validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode)
('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode); || ('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode);
return $validTrigger && ($this->allRules || in_array($rule->id, $this->rulesToApply, true)); return $validTrigger && ($this->allRules || in_array($rule->id, $this->rulesToApply, true));
} }

View File

@ -78,11 +78,11 @@ class TriggerFactory
* @param string $triggerValue * @param string $triggerValue
* @param bool $stopProcessing * @param bool $stopProcessing
* *
* @see TriggerFactory::getTrigger
*
* @return AbstractTrigger * @return AbstractTrigger
* *
* @throws FireflyException * @throws FireflyException
* @see TriggerFactory::getTrigger
*
*/ */
public static function makeTriggerFromStrings(string $triggerType, string $triggerValue, bool $stopProcessing): AbstractTrigger public static function makeTriggerFromStrings(string $triggerType, string $triggerValue, bool $stopProcessing): AbstractTrigger
{ {

View File

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules; namespace FireflyIII\TransactionRules;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Rule; use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
use FireflyIII\Models\RuleTrigger; use FireflyIII\Models\RuleTrigger;
@ -62,16 +63,71 @@ class Processor
$this->actions = new Collection; $this->actions = new Collection;
} }
/**
* Return found triggers
*
* @return int
*/
public function getFoundTriggers(): int
{
return $this->foundTriggers;
}
/**
* Set found triggers
*
* @param int $foundTriggers
*/
public function setFoundTriggers(int $foundTriggers): void
{
$this->foundTriggers = $foundTriggers;
}
/** /**
* Returns the rule * Returns the rule
* *
* @return \FireflyIII\Models\Rule * @return Rule
*/ */
public function getRule(): Rule public function getRule(): Rule
{ {
return $this->rule; return $this->rule;
} }
/**
* This method will scan the given transaction journal and check if it matches the triggers found in the Processor
* If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal
* matches all of the triggers (regardless of whether the Processor could act on it).
*
* @param array $journal
*
* @return bool
* @throws FireflyException
*/
public function handleJournalArray(array $journal): bool
{
Log::debug(sprintf('handleJournalArray for journal #%d (group #%d)', $journal['transaction_journal_id'], $journal['transaction_group_id']));
// grab the actual journal.
$this->journal = TransactionJournal::find($journal['transaction_journal_id']);
// get all triggers:
$triggered = $this->triggered();
if ($triggered) {
Log::debug('Rule is triggered, go to actions.');
if ($this->actions->count() > 0) {
Log::debug('Has more than zero actions.');
$this->actions();
}
if (0 === $this->actions->count()) {
Log::info('Rule has no actions!');
}
return true;
}
return false;
}
/** /**
* This method will scan the given transaction journal and check if it matches the triggers found in the Processor * This method will scan the given transaction journal and check if it matches the triggers found in the Processor
* If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal
@ -80,7 +136,7 @@ class Processor
* @param Transaction $transaction * @param Transaction $transaction
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
public function handleTransaction(Transaction $transaction): bool public function handleTransaction(Transaction $transaction): bool
{ {
@ -107,6 +163,140 @@ class Processor
return false; return false;
} }
/**
* This method will scan the given transaction journal and check if it matches the triggers found in the Processor
* If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal
* matches all of the triggers (regardless of whether the Processor could act on it).
*
* @param TransactionJournal $journal
*
* @return bool
* @throws FireflyException
*/
public function handleTransactionJournal(TransactionJournal $journal): bool
{
Log::debug(sprintf('handleTransactionJournal for journal %d', $journal->id));
$this->journal = $journal;
// get all triggers:
$triggered = $this->triggered();
if ($triggered) {
if ($this->actions->count() > 0) {
$this->actions();
}
return true;
}
return false;
}
/**
* @return bool
*/
public function isStrict(): bool
{
return $this->strict;
}
/**
* @param bool $strict
*/
public function setStrict(bool $strict): void
{
$this->strict = $strict;
}
/**
* This method will make a Processor that will process each transaction journal using the triggers
* and actions found in the given Rule.
*
* @param Rule $rule
* @param bool $includeActions
*
* @throws FireflyException
*/
public function make(Rule $rule, bool $includeActions = null): void
{
$includeActions = $includeActions ?? true;
Log::debug(sprintf('Making new rule from Rule %d', $rule->id));
Log::debug(sprintf('Rule is strict: %s', var_export($rule->strict, true)));
$this->rule = $rule;
$this->strict = $rule->strict;
$triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
/** @var RuleTrigger $trigger */
foreach ($triggerSet as $trigger) {
Log::debug(sprintf('Push trigger %d', $trigger->id));
$this->triggers->push(TriggerFactory::getTrigger($trigger));
}
if (true === $includeActions) {
$this->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get();
}
}
/**
* This method will make a Processor that will process each transaction journal using the given
* trigger (singular!). It can only report if the transaction journal was hit by the given trigger
* and will not be able to act on it using actions.
*
* @param string $triggerName
* @param string $triggerValue
*
* @throws FireflyException
*/
public function makeFromString(string $triggerName, string $triggerValue): void
{
Log::debug(sprintf('Processor::makeFromString("%s", "%s")', $triggerName, $triggerValue));
$trigger = TriggerFactory::makeTriggerFromStrings($triggerName, $triggerValue, false);
$this->triggers->push($trigger);
}
/**
* This method will make a Processor that will process each transaction journal using the given
* triggers. It can only report if the transaction journal was hit by the given triggers
* and will not be able to act on it using actions.
*
* The given triggers must be in the following format:
*
* [type => xx, value => yy, stop_processing => bool], [type => xx, value => yy, stop_processing => bool],
*
* @param array $triggers
*
* @throws FireflyException
*/
public function makeFromStringArray(array $triggers): void
{
foreach ($triggers as $entry) {
$entry['value'] = $entry['value'] ?? '';
$trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stop_processing']);
$this->triggers->push($trigger);
}
}
/**
* Run the actions
*
* @return void
* @throws FireflyException
*/
private function actions(): void
{
/**
* @var int
* @var RuleAction $action
*/
foreach ($this->actions as $action) {
/** @var ActionInterface $actionClass */
$actionClass = ActionFactory::getAction($action);
Log::debug(sprintf('Fire action %s on journal #%d', get_class($actionClass), $this->journal->id));
$actionClass->act($this->journal);
if ($action->stop_processing) {
Log::debug('Stop processing now and break.');
break;
}
}
}
/** /**
* Method to check whether the current transaction would be triggered * Method to check whether the current transaction would be triggered
* by the given list of triggers. * by the given list of triggers.
@ -147,193 +337,4 @@ class Processor
return $result; return $result;
} }
/**
* Return found triggers
*
* @return int
*/
public function getFoundTriggers(): int
{
return $this->foundTriggers;
}
/**
* Set found triggers
*
* @param int $foundTriggers
*/
public function setFoundTriggers(int $foundTriggers): void
{
$this->foundTriggers = $foundTriggers;
}
/**
* Run the actions
*
* @return void
* @throws \FireflyIII\Exceptions\FireflyException
*/
private function actions(): void
{
/**
* @var int
* @var RuleAction $action
*/
foreach ($this->actions as $action) {
/** @var ActionInterface $actionClass */
$actionClass = ActionFactory::getAction($action);
Log::debug(sprintf('Fire action %s on journal #%d', get_class($actionClass), $this->journal->id));
$actionClass->act($this->journal);
if ($action->stop_processing) {
Log::debug('Stop processing now and break.');
break;
}
}
}
/**
* This method will scan the given transaction journal and check if it matches the triggers found in the Processor
* If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal
* matches all of the triggers (regardless of whether the Processor could act on it).
*
* @param array $journal
*
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function handleJournalArray(array $journal): bool
{
Log::debug(sprintf('handleJournalArray for journal #%d (group #%d)', $journal['transaction_journal_id'], $journal['transaction_group_id']));
// grab the actual journal.
$this->journal = TransactionJournal::find($journal['transaction_journal_id']);
// get all triggers:
$triggered = $this->triggered();
if ($triggered) {
Log::debug('Rule is triggered, go to actions.');
if ($this->actions->count() > 0) {
Log::debug('Has more than zero actions.');
$this->actions();
}
if (0 === $this->actions->count()) {
Log::info('Rule has no actions!');
}
return true;
}
return false;
}
/**
* This method will scan the given transaction journal and check if it matches the triggers found in the Processor
* If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal
* matches all of the triggers (regardless of whether the Processor could act on it).
*
* @param TransactionJournal $journal
*
* @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function handleTransactionJournal(TransactionJournal $journal): bool
{
Log::debug(sprintf('handleTransactionJournal for journal %d', $journal->id));
$this->journal = $journal;
// get all triggers:
$triggered = $this->triggered();
if ($triggered) {
if ($this->actions->count() > 0) {
$this->actions();
}
return true;
}
return false;
}
/**
* @return bool
*/
public function isStrict(): bool
{
return $this->strict;
}
/**
* @param bool $strict
*/
public function setStrict(bool $strict): void
{
$this->strict = $strict;
}
/**
* This method will make a Processor that will process each transaction journal using the triggers
* and actions found in the given Rule.
*
* @param Rule $rule
* @param bool $includeActions
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function make(Rule $rule, bool $includeActions = null): void
{
$includeActions = $includeActions ?? true;
Log::debug(sprintf('Making new rule from Rule %d', $rule->id));
Log::debug(sprintf('Rule is strict: %s', var_export($rule->strict, true)));
$this->rule = $rule;
$this->strict = $rule->strict;
$triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
/** @var RuleTrigger $trigger */
foreach ($triggerSet as $trigger) {
Log::debug(sprintf('Push trigger %d', $trigger->id));
$this->triggers->push(TriggerFactory::getTrigger($trigger));
}
if (true === $includeActions) {
$this->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get();
}
}
/**
* This method will make a Processor that will process each transaction journal using the given
* trigger (singular!). It can only report if the transaction journal was hit by the given trigger
* and will not be able to act on it using actions.
*
* @param string $triggerName
* @param string $triggerValue
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function makeFromString(string $triggerName, string $triggerValue): void
{
Log::debug(sprintf('Processor::makeFromString("%s", "%s")', $triggerName, $triggerValue));
$trigger = TriggerFactory::makeTriggerFromStrings($triggerName, $triggerValue, false);
$this->triggers->push($trigger);
}
/**
* This method will make a Processor that will process each transaction journal using the given
* triggers. It can only report if the transaction journal was hit by the given triggers
* and will not be able to act on it using actions.
*
* The given triggers must be in the following format:
*
* [type => xx, value => yy, stop_processing => bool], [type => xx, value => yy, stop_processing => bool],
*
* @param array $triggers
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function makeFromStringArray(array $triggers): void
{
foreach ($triggers as $entry) {
$entry['value'] = $entry['value'] ?? '';
$trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stop_processing']);
$this->triggers->push($trigger);
}
}
} }

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules; namespace FireflyIII\TransactionRules;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Rule; use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleTrigger; use FireflyIII\Models\RuleTrigger;
@ -78,7 +79,7 @@ class TransactionMatcher
* triggers onto each transaction journal until enough matches are found ($limit). * triggers onto each transaction journal until enough matches are found ($limit).
* *
* @return array * @return array
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
public function findTransactionsByRule(): array public function findTransactionsByRule(): array
{ {
@ -108,7 +109,7 @@ class TransactionMatcher
* triggers onto each transaction journal until enough matches are found ($limit). * triggers onto each transaction journal until enough matches are found ($limit).
* *
* @return array * @return array
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
public function findTransactionsByTriggers(): array public function findTransactionsByTriggers(): array
{ {

View File

@ -127,7 +127,7 @@ class BillTransformer extends AbstractTransformer
* @param Bill $bill * @param Bill $bill
* @param Carbon $date * @param Carbon $date
* *
* @return \Carbon\Carbon * @return Carbon
*/ */
protected function nextDateMatch(Bill $bill, Carbon $date): Carbon protected function nextDateMatch(Bill $bill, Carbon $date): Carbon
{ {

View File

@ -24,10 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Transformers; namespace FireflyIII\Transformers;
use Carbon\Carbon;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;

View File

@ -46,8 +46,6 @@ use Illuminate\Validation\Validator;
class FireflyValidator extends Validator class FireflyValidator extends Validator
{ {
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* *
@ -65,8 +63,6 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* @param $parameters * @param $parameters
@ -86,8 +82,6 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* *
@ -108,8 +102,6 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* *
@ -191,8 +183,6 @@ class FireflyValidator extends Validator
* @param $attribute * @param $attribute
* @param $value * @param $value
* @param $parameters * @param $parameters
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool * @return bool
*/ */
public function validateLess($attribute, $value, $parameters): bool public function validateLess($attribute, $value, $parameters): bool
@ -207,8 +197,6 @@ class FireflyValidator extends Validator
* @param $attribute * @param $attribute
* @param $value * @param $value
* @param $parameters * @param $parameters
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool * @return bool
*/ */
public function validateMore($attribute, $value, $parameters): bool public function validateMore($attribute, $value, $parameters): bool
@ -220,8 +208,6 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* @param $parameters * @param $parameters
@ -381,8 +367,6 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* @param $parameters * @param $parameters
@ -415,8 +399,6 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* @param $parameters * @param $parameters
@ -452,7 +434,7 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) *
* Validate an object and its unicity. Checks for encryption / encrypted values as well. * Validate an object and its unicity. Checks for encryption / encrypted values as well.
* *
* parameter 0: the table * parameter 0: the table
@ -496,8 +478,6 @@ class FireflyValidator extends Validator
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute * @param $attribute
* @param $value * @param $value
* @param $parameters * @param $parameters