Code clean up.

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

View File

@@ -18,10 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use Carbon\Carbon; use Carbon\Carbon;
@@ -35,11 +33,9 @@ use Illuminate\Console\Command;
use Storage; use Storage;
/** /**
* Class CreateExport * Class CreateExport.
* *
* Generates export from the command line. * Generates export from the command line.
*
* @package FireflyIII\Console\Commands
*/ */
class CreateExport extends Command class CreateExport extends Command
{ {
@@ -65,7 +61,6 @@ class CreateExport extends Command
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {
@@ -73,7 +68,6 @@ class CreateExport extends Command
} }
/** /**
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* *
@@ -108,7 +102,7 @@ class CreateExport extends Command
// first date // first date
$firstJournal = $journalRepository->first(); $firstJournal = $journalRepository->first();
$first = new Carbon; $first = new Carbon;
if (!is_null($firstJournal->id)) { if (null !== $firstJournal->id) {
$first = $firstJournal->date; $first = $firstJournal->date;
} }
@@ -124,7 +118,6 @@ class CreateExport extends Command
'job' => $job, 'job' => $job,
]; ];
/** @var ProcessorInterface $processor */ /** @var ProcessorInterface $processor */
$processor = app(ProcessorInterface::class); $processor = app(ProcessorInterface::class);
$processor->setSettings($settings); $processor->setSettings($settings);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -35,9 +34,7 @@ use Monolog\Formatter\LineFormatter;
use Preferences; use Preferences;
/** /**
* Class CreateImport * Class CreateImport.
*
* @package FireflyIII\Console\Commands
*/ */
class CreateImport extends Command class CreateImport extends Command
{ {
@@ -65,7 +62,6 @@ class CreateImport extends Command
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {
@@ -98,7 +94,7 @@ class CreateImport extends Command
} }
$configurationData = json_decode(file_get_contents($configuration)); $configurationData = json_decode(file_get_contents($configuration));
if (is_null($configurationData)) { if (null === $configurationData) {
$this->error(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd)); $this->error(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));
return; return;
@@ -109,25 +105,21 @@ class CreateImport extends Command
$this->line(sprintf('Import into user: #%d (%s)', $user->id, $user->email)); $this->line(sprintf('Import into user: #%d (%s)', $user->id, $user->email));
$this->line(sprintf('Type of import: %s', $type)); $this->line(sprintf('Type of import: %s', $type));
/** @var ImportJobRepositoryInterface $jobRepository */ /** @var ImportJobRepositoryInterface $jobRepository */
$jobRepository = app(ImportJobRepositoryInterface::class); $jobRepository = app(ImportJobRepositoryInterface::class);
$jobRepository->setUser($user); $jobRepository->setUser($user);
$job = $jobRepository->create($type); $job = $jobRepository->create($type);
$this->line(sprintf('Created job "%s"', $job->key)); $this->line(sprintf('Created job "%s"', $job->key));
Artisan::call('firefly:encrypt-file', ['file' => $file, 'key' => $job->key]); Artisan::call('firefly:encrypt-file', ['file' => $file, 'key' => $job->key]);
$this->line('Stored import data...'); $this->line('Stored import data...');
$job->configuration = $configurationData; $job->configuration = $configurationData;
$job->status = 'configured'; $job->status = 'configured';
$job->save(); $job->save();
$this->line('Stored configuration...'); $this->line('Stored configuration...');
if (true === $this->option('start')) {
if ($this->option('start') === true) {
$this->line('The import will start in a moment. This process is not visible...'); $this->line('The import will start in a moment. This process is not visible...');
Log::debug('Go for import!'); Log::debug('Go for import!');
@@ -138,7 +130,6 @@ class CreateImport extends Command
$handler->setFormatter($formatter); $handler->setFormatter($formatter);
$monolog->pushHandler($handler); $monolog->pushHandler($handler);
// start the actual routine: // start the actual routine:
/** @var ImportRoutine $routine */ /** @var ImportRoutine $routine */
$routine = app(ImportRoutine::class); $routine = app(ImportRoutine::class);
@@ -177,7 +168,7 @@ class CreateImport extends Command
$cwd = getcwd(); $cwd = getcwd();
$validTypes = array_keys(config('firefly.import_formats')); $validTypes = array_keys(config('firefly.import_formats'));
$type = strtolower($this->option('type')); $type = strtolower($this->option('type'));
if (is_null($user->id)) { if (null === $user->id) {
$this->error(sprintf('There is no user with ID %d.', $this->option('user'))); $this->error(sprintf('There is no user with ID %d.', $this->option('user')));
return false; return false;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -28,9 +27,7 @@ use Illuminate\Console\Command;
use Log; use Log;
/** /**
* Class DecryptAttachment * Class DecryptAttachment.
*
* @package FireflyIII\Console\Commands
*/ */
class DecryptAttachment extends Command class DecryptAttachment extends Command
{ {
@@ -50,10 +47,8 @@ class DecryptAttachment extends Command
= 'firefly:decrypt-attachment {id:The ID of the attachment.} {name:The file name of the attachment.} = 'firefly:decrypt-attachment {id:The ID of the attachment.} {name:The file name of the attachment.}
{directory:Where the file must be stored.}'; {directory:Where the file must be stored.}';
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {
@@ -65,7 +60,6 @@ class DecryptAttachment extends Command
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
*/ */
public function handle() public function handle()
{ {
@@ -75,7 +69,7 @@ class DecryptAttachment extends Command
$attachment = $repository->findWithoutUser($attachmentId); $attachment = $repository->findWithoutUser($attachmentId);
$attachmentName = trim($this->argument('name')); $attachmentName = trim($this->argument('name'));
$storagePath = realpath(trim($this->argument('directory'))); $storagePath = realpath(trim($this->argument('directory')));
if (is_null($attachment->id)) { if (null === $attachment->id) {
$this->error(sprintf('No attachment with id #%d', $attachmentId)); $this->error(sprintf('No attachment with id #%d', $attachmentId));
Log::error(sprintf('DecryptAttachment: No attachment with id #%d', $attachmentId)); Log::error(sprintf('DecryptAttachment: No attachment with id #%d', $attachmentId));
@@ -107,7 +101,7 @@ class DecryptAttachment extends Command
$content = $repository->getContent($attachment); $content = $repository->getContent($attachment);
$this->line(sprintf('Going to write content for attachment #%d into file "%s"', $attachment->id, $fullPath)); $this->line(sprintf('Going to write content for attachment #%d into file "%s"', $attachment->id, $fullPath));
$result = file_put_contents($fullPath, $content); $result = file_put_contents($fullPath, $content);
if ($result === false) { if (false === $result) {
$this->error('Could not write to file.'); $this->error('Could not write to file.');
return; return;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -27,9 +26,7 @@ use Crypt;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** /**
* Class EncryptFile * Class EncryptFile.
*
* @package FireflyIII\Console\Commands
*/ */
class EncryptFile extends Command class EncryptFile extends Command
{ {
@@ -49,7 +46,6 @@ class EncryptFile extends Command
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -31,9 +30,7 @@ use Illuminate\Support\MessageBag;
use Log; use Log;
/** /**
* Class Import * Class Import.
*
* @package FireflyIII\Console\Commands
*/ */
class Import extends Command class Import extends Command
{ {
@@ -53,7 +50,6 @@ class Import extends Command
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {
@@ -68,7 +64,7 @@ class Import extends Command
Log::debug('Start start-import command'); Log::debug('Start start-import command');
$jobKey = $this->argument('key'); $jobKey = $this->argument('key');
$job = ImportJob::where('key', $jobKey)->first(); $job = ImportJob::where('key', $jobKey)->first();
if (is_null($job)) { if (null === $job) {
$this->error(sprintf('No job found with key "%s"', $jobKey)); $this->error(sprintf('No job found with key "%s"', $jobKey));
return; return;
@@ -109,14 +105,14 @@ class Import extends Command
*/ */
private function isValid(ImportJob $job): bool private function isValid(ImportJob $job): bool
{ {
if (is_null($job)) { if (null === $job) {
Log::error('This job does not seem to exist.'); Log::error('This job does not seem to exist.');
$this->error('This job does not seem to exist.'); $this->error('This job does not seem to exist.');
return false; return false;
} }
if ($job->status !== 'configured') { if ('configured' !== $job->status) {
Log::error(sprintf('This job is not ready to be imported (status is %s).', $job->status)); Log::error(sprintf('This job is not ready to be imported (status is %s).', $job->status));
$this->error('This job is not ready to be imported.'); $this->error('This job is not ready to be imported.');

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -31,9 +30,7 @@ use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Storage; use Storage;
/** /**
* Class ScanAttachments * Class ScanAttachments.
*
* @package FireflyIII\Console\Commands
*/ */
class ScanAttachments extends Command class ScanAttachments extends Command
{ {
@@ -53,7 +50,6 @@ class ScanAttachments extends Command
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -44,17 +43,15 @@ use Preferences;
use Schema; use Schema;
/** /**
* Class UpgradeDatabase * Class UpgradeDatabase.
* *
* Upgrade user database. * Upgrade user database.
* *
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it just touches a lot of things. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it just touches a lot of things.
* @package FireflyIII\Console\Commands
*/ */
class UpgradeDatabase extends Command class UpgradeDatabase extends Command
{ {
/** /**
* The console command description. * The console command description.
* *
@@ -105,7 +102,7 @@ class UpgradeDatabase extends Command
foreach ($set as $budgetLimit) { foreach ($set as $budgetLimit) {
/** @var LimitRepetition $repetition */ /** @var LimitRepetition $repetition */
$repetition = $budgetLimit->limitrepetitions()->first(); $repetition = $budgetLimit->limitrepetitions()->first();
if (!is_null($repetition)) { if (null !== $repetition) {
$budgetLimit->end_date = $repetition->enddate; $budgetLimit->end_date = $repetition->enddate;
$budgetLimit->save(); $budgetLimit->save();
$this->line(sprintf('Updated budget limit #%d', $budgetLimit->id)); $this->line(sprintf('Updated budget limit #%d', $budgetLimit->id));
@@ -170,7 +167,7 @@ class UpgradeDatabase extends Command
$obCurrency = intval($openingBalance->transaction_currency_id); $obCurrency = intval($openingBalance->transaction_currency_id);
// both 0? set to default currency: // both 0? set to default currency:
if ($accountCurrency === 0 && $obCurrency === 0) { if (0 === $accountCurrency && 0 === $obCurrency) {
AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $defaultCurrency->id]); AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $defaultCurrency->id]);
$this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode)); $this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode));
@@ -178,7 +175,7 @@ class UpgradeDatabase extends Command
} }
// account is set to 0, opening balance is not? // account is set to 0, opening balance is not?
if ($accountCurrency === 0 && $obCurrency > 0) { if (0 === $accountCurrency && $obCurrency > 0) {
AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $obCurrency]); AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $obCurrency]);
$this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode)); $this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode));
@@ -228,7 +225,7 @@ class UpgradeDatabase extends Command
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->whereIn('account_types.type', [AccountType::DEFAULT, AccountType::ASSET])->first(['transactions.*']); ->whereIn('account_types.type', [AccountType::DEFAULT, AccountType::ASSET])->first(['transactions.*']);
if (is_null($transaction)) { if (null === $transaction) {
return; return;
} }
/** @var Account $account */ /** @var Account $account */
@@ -237,7 +234,7 @@ class UpgradeDatabase extends Command
$transactions = $journal->transactions()->get(); $transactions = $journal->transactions()->get();
$transactions->each( $transactions->each(
function (Transaction $transaction) use ($currency) { function (Transaction $transaction) use ($currency) {
if (is_null($transaction->transaction_currency_id)) { if (null === $transaction->transaction_currency_id) {
$transaction->transaction_currency_id = $currency->id; $transaction->transaction_currency_id = $currency->id;
$transaction->save(); $transaction->save();
} }
@@ -302,7 +299,7 @@ class UpgradeDatabase extends Command
foreach ($set as $meta) { foreach ($set as $meta) {
$journal = $meta->transactionJournal; $journal = $meta->transactionJournal;
$note = $journal->notes()->first(); $note = $journal->notes()->first();
if (is_null($note)) { if (null === $note) {
$note = new Note; $note = new Note;
$note->noteable()->associate($journal); $note->noteable()->associate($journal);
} }
@@ -314,7 +311,6 @@ class UpgradeDatabase extends Command
} }
} }
/** /**
* This method makes sure that the transaction journal uses the currency given in the transaction. * This method makes sure that the transaction journal uses the currency given in the transaction.
* *
@@ -375,7 +371,7 @@ class UpgradeDatabase extends Command
return; return;
} }
if (!is_null($opposing)) { if (null !== $opposing) {
// give both a new identifier: // give both a new identifier:
$transaction->identifier = $identifier; $transaction->identifier = $identifier;
$opposing->identifier = $identifier; $opposing->identifier = $identifier;
@@ -384,7 +380,7 @@ class UpgradeDatabase extends Command
$processed[] = $transaction->id; $processed[] = $transaction->id;
$processed[] = $opposing->id; $processed[] = $opposing->id;
} }
$identifier++; ++$identifier;
} }
return; return;
@@ -411,7 +407,7 @@ class UpgradeDatabase extends Command
$currency = $repository->find(intval($transaction->account->getMeta('currency_id'))); $currency = $repository->find(intval($transaction->account->getMeta('currency_id')));
// has no currency ID? Must have, so fill in using account preference: // has no currency ID? Must have, so fill in using account preference:
if (is_null($transaction->transaction_currency_id)) { if (null === $transaction->transaction_currency_id) {
$transaction->transaction_currency_id = $currency->id; $transaction->transaction_currency_id = $currency->id;
Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code)); Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code));
$transaction->save(); $transaction->save();
@@ -419,7 +415,7 @@ class UpgradeDatabase extends Command
// does not match the source account (see above)? Can be fixed // does not match the source account (see above)? Can be fixed
// when mismatch in transaction and NO foreign amount is set: // when mismatch in transaction and NO foreign amount is set:
if ($transaction->transaction_currency_id !== $currency->id && is_null($transaction->foreign_amount)) { if ($transaction->transaction_currency_id !== $currency->id && null === $transaction->foreign_amount) {
Log::debug( Log::debug(
sprintf( sprintf(
'Transaction #%d has a currency setting (#%d) that should be #%d. Amount remains %s, currency is changed.', 'Transaction #%d has a currency setting (#%d) that should be #%d. Amount remains %s, currency is changed.',
@@ -440,7 +436,7 @@ class UpgradeDatabase extends Command
$opposing = $journal->transactions()->where('amount', '>', 0)->where('identifier', $transaction->identifier)->first(); $opposing = $journal->transactions()->where('amount', '>', 0)->where('identifier', $transaction->identifier)->first();
$opposingCurrency = $repository->find(intval($opposing->account->getMeta('currency_id'))); $opposingCurrency = $repository->find(intval($opposing->account->getMeta('currency_id')));
if (is_null($opposingCurrency->id)) { if (null === $opposingCurrency->id) {
Log::error(sprintf('Account #%d ("%s") must have currency preference but has none.', $opposing->account->id, $opposing->account->name)); Log::error(sprintf('Account #%d ("%s") must have currency preference but has none.', $opposing->account->id, $opposing->account->name));
return; return;
@@ -470,23 +466,23 @@ class UpgradeDatabase extends Command
} }
// if foreign amount of one is null and the other is not, use this to restore: // if foreign amount of one is null and the other is not, use this to restore:
if (is_null($transaction->foreign_amount) && !is_null($opposing->foreign_amount)) { if (null === $transaction->foreign_amount && null !== $opposing->foreign_amount) {
$transaction->foreign_amount = bcmul(strval($opposing->foreign_amount), '-1'); $transaction->foreign_amount = bcmul(strval($opposing->foreign_amount), '-1');
$transaction->save(); $transaction->save();
Log::debug(sprintf('Restored foreign amount of transaction (1) #%d to %s', $transaction->id, $transaction->foreign_amount)); Log::debug(sprintf('Restored foreign amount of transaction (1) #%d to %s', $transaction->id, $transaction->foreign_amount));
} }
// if foreign amount of one is null and the other is not, use this to restore (other way around) // if foreign amount of one is null and the other is not, use this to restore (other way around)
if (is_null($opposing->foreign_amount) && !is_null($transaction->foreign_amount)) { if (null === $opposing->foreign_amount && null !== $transaction->foreign_amount) {
$opposing->foreign_amount = bcmul(strval($transaction->foreign_amount), '-1'); $opposing->foreign_amount = bcmul(strval($transaction->foreign_amount), '-1');
$opposing->save(); $opposing->save();
Log::debug(sprintf('Restored foreign amount of transaction (2) #%d to %s', $opposing->id, $opposing->foreign_amount)); Log::debug(sprintf('Restored foreign amount of transaction (2) #%d to %s', $opposing->id, $opposing->foreign_amount));
} }
// when both are zero, try to grab it from journal: // when both are zero, try to grab it from journal:
if (is_null($opposing->foreign_amount) && is_null($transaction->foreign_amount)) { if (null === $opposing->foreign_amount && null === $transaction->foreign_amount) {
$foreignAmount = $journal->getMeta('foreign_amount'); $foreignAmount = $journal->getMeta('foreign_amount');
if (is_null($foreignAmount)) { if (null === $foreignAmount) {
Log::debug(sprintf('Journal #%d has missing foreign currency data, forced to do 1:1 conversion :(.', $transaction->transaction_journal_id)); Log::debug(sprintf('Journal #%d has missing foreign currency data, forced to do 1:1 conversion :(.', $transaction->transaction_journal_id));
$transaction->foreign_amount = bcmul(strval($transaction->amount), '-1'); $transaction->foreign_amount = bcmul(strval($transaction->amount), '-1');
$opposing->foreign_amount = bcmul(strval($opposing->amount), '-1'); $opposing->foreign_amount = bcmul(strval($opposing->amount), '-1');
@@ -509,7 +505,6 @@ class UpgradeDatabase extends Command
$opposing->save(); $opposing->save();
} }
return; return;
} }
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -26,9 +25,7 @@ namespace FireflyIII\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** /**
* Class UpgradeFireflyInstructions * Class UpgradeFireflyInstructions.
*
* @package FireflyIII\Console\Commands
*/ */
class UpgradeFireflyInstructions extends Command class UpgradeFireflyInstructions extends Command
{ {
@@ -47,7 +44,6 @@ class UpgradeFireflyInstructions extends Command
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {
@@ -59,16 +55,16 @@ class UpgradeFireflyInstructions extends Command
*/ */
public function handle() public function handle()
{ {
if ($this->argument('task') === 'update') { if ('update' === $this->argument('task')) {
$this->updateInstructions(); $this->updateInstructions();
} }
if ($this->argument('task') === 'install') { if ('install' === $this->argument('task')) {
$this->installInstructions(); $this->installInstructions();
} }
} }
/** /**
* Show a nice box * Show a nice box.
* *
* @param string $text * @param string $text
*/ */
@@ -81,7 +77,7 @@ class UpgradeFireflyInstructions extends Command
} }
/** /**
* Show a nice info box * Show a nice info box.
* *
* @param string $text * @param string $text
*/ */
@@ -111,7 +107,7 @@ class UpgradeFireflyInstructions extends Command
} }
$this->showLine(); $this->showLine();
$this->boxed(''); $this->boxed('');
if (is_null($text)) { if (null === $text) {
$this->boxed(sprintf('Thank you for installing Firefly III, v%s!', $version)); $this->boxed(sprintf('Thank you for installing Firefly III, v%s!', $version));
$this->boxedInfo('There are no extra installation instructions.'); $this->boxedInfo('There are no extra installation instructions.');
$this->boxed('Firefly III should be ready for use.'); $this->boxed('Firefly III should be ready for use.');
@@ -128,12 +124,12 @@ class UpgradeFireflyInstructions extends Command
} }
/** /**
* Show a line * Show a line.
*/ */
private function showLine() private function showLine()
{ {
$line = '+'; $line = '+';
for ($i = 0; $i < 78; $i++) { for ($i = 0; $i < 78; ++$i) {
$line .= '-'; $line .= '-';
} }
$line .= '+'; $line .= '+';
@@ -158,7 +154,7 @@ class UpgradeFireflyInstructions extends Command
} }
$this->showLine(); $this->showLine();
$this->boxed(''); $this->boxed('');
if (is_null($text)) { if (null === $text) {
$this->boxed(sprintf('Thank you for updating to Firefly III, v%s', $version)); $this->boxed(sprintf('Thank you for updating to Firefly III, v%s', $version));
$this->boxedInfo('There are no extra upgrade instructions.'); $this->boxedInfo('There are no extra upgrade instructions.');
$this->boxed('Firefly III should be ready for use.'); $this->boxed('Firefly III should be ready for use.');

View File

@@ -19,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
/** /**
@@ -36,9 +35,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Str; use Illuminate\Support\Str;
/** /**
* Class UseEncryption * Class UseEncryption.
*
* @package FireflyIII\Console\Commands
*/ */
class UseEncryption extends Command class UseEncryption extends Command
{ {
@@ -57,7 +54,6 @@ class UseEncryption extends Command
/** /**
* Create a new command instance. * Create a new command instance.
*
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -28,11 +27,9 @@ use Log;
use Preferences; use Preferences;
/** /**
* Trait VerifiesAccessToken * Trait VerifiesAccessToken.
* *
* Verifies user access token for sensitive commands. * Verifies user access token for sensitive commands.
*
* @package FireflyIII\Console\Commands
*/ */
trait VerifiesAccessToken trait VerifiesAccessToken
{ {
@@ -58,13 +55,13 @@ trait VerifiesAccessToken
$repository = app(UserRepositoryInterface::class); $repository = app(UserRepositoryInterface::class);
$user = $repository->find($userId); $user = $repository->find($userId);
if (is_null($user->id)) { if (null === $user->id) {
Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId)); Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
return false; return false;
} }
$accessToken = Preferences::getForUser($user, 'access_token', null); $accessToken = Preferences::getForUser($user, 'access_token', null);
if (is_null($accessToken)) { if (null === $accessToken) {
Log::error(sprintf('User #%d has no access token, so cannot access command line options.', $userId)); Log::error(sprintf('User #%d has no access token, so cannot access command line options.', $userId));
return false; return false;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -42,11 +41,9 @@ use Schema;
use stdClass; use stdClass;
/** /**
* Class VerifyDatabase * Class VerifyDatabase.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*
* @package FireflyIII\Console\Commands
*/ */
class VerifyDatabase extends Command class VerifyDatabase extends Command
{ {
@@ -107,7 +104,7 @@ class VerifyDatabase extends Command
/** @var User $user */ /** @var User $user */
foreach ($users as $user) { foreach ($users as $user) {
$pref = Preferences::getForUser($user, 'access_token', null); $pref = Preferences::getForUser($user, 'access_token', null);
if (is_null($pref)) { if (null === $pref) {
$token = $user->generateAccessToken(); $token = $user->generateAccessToken();
Preferences::setForUser($user, 'access_token', $token); Preferences::setForUser($user, 'access_token', $token);
$this->line(sprintf('Generated access token for user %s', $user->email)); $this->line(sprintf('Generated access token for user %s', $user->email));
@@ -128,7 +125,7 @@ class VerifyDatabase extends Command
]; ];
foreach ($set as $name => $values) { foreach ($set as $name => $values) {
$link = LinkType::where('name', $name)->where('outward', $values[0])->where('inward', $values[1])->first(); $link = LinkType::where('name', $name)->where('outward', $values[0])->where('inward', $values[1])->first();
if (is_null($link)) { if (null === $link) {
$link = new LinkType; $link = new LinkType;
$link->name = $name; $link->name = $name;
$link->outward = $values[0]; $link->outward = $values[0];
@@ -147,17 +144,17 @@ class VerifyDatabase extends Command
$set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get(); $set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();
$set->each( $set->each(
function (PiggyBankEvent $event) { function (PiggyBankEvent $event) {
if (is_null($event->transaction_journal_id)) { if (null === $event->transaction_journal_id) {
return true; return true;
} }
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
$journal = $event->transactionJournal()->first(); $journal = $event->transactionJournal()->first();
if (is_null($journal)) { if (null === $journal) {
return true; return true;
} }
$type = $journal->transactionType->type; $type = $journal->transactionType->type;
if ($type !== TransactionType::TRANSFER) { if (TransactionType::TRANSFER !== $type) {
$event->transaction_journal_id = null; $event->transaction_journal_id = null;
$event->save(); $event->save();
$this->line(sprintf('Piggy bank #%d was referenced by an invalid event. This has been fixed.', $event->piggy_bank_id)); $this->line(sprintf('Piggy bank #%d was referenced by an invalid event. This has been fixed.', $event->piggy_bank_id));
@@ -234,11 +231,11 @@ class VerifyDatabase extends Command
->get( ->get(
['accounts.id as account_id', 'accounts.deleted_at as account_deleted_at', 'transactions.id as transaction_id', ['accounts.id as account_id', 'accounts.deleted_at as account_deleted_at', 'transactions.id as transaction_id',
'transactions.deleted_at as transaction_deleted_at', 'transaction_journals.id as journal_id', 'transactions.deleted_at as transaction_deleted_at', 'transaction_journals.id as journal_id',
'transaction_journals.deleted_at as journal_deleted_at'] 'transaction_journals.deleted_at as journal_deleted_at',]
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at; $date = null === $entry->transaction_deleted_at ? $entry->journal_deleted_at : $entry->transaction_deleted_at;
$this->error( $this->error(
'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' . 'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' .
' Find it in the table called "accounts" and change the "deleted_at" field to: "' . $date . '"' ' Find it in the table called "accounts" and change the "deleted_at" field to: "' . $date . '"'
@@ -270,7 +267,7 @@ class VerifyDatabase extends Command
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->get( ->get(
['transaction_journals.id', 'transaction_journals.user_id', 'users.email', 'account_types.type as a_type', ['transaction_journals.id', 'transaction_journals.user_id', 'users.email', 'account_types.type as a_type',
'transaction_types.type'] 'transaction_types.type',]
); );
foreach ($set as $entry) { foreach ($set as $entry) {
$this->error( $this->error(
@@ -289,7 +286,7 @@ class VerifyDatabase extends Command
} }
/** /**
* Any deleted transaction journals that have transactions that are NOT deleted: * Any deleted transaction journals that have transactions that are NOT deleted:.
*/ */
private function reportJournals() private function reportJournals()
{ {
@@ -303,7 +300,7 @@ class VerifyDatabase extends Command
'transaction_journals.description', 'transaction_journals.description',
'transaction_journals.deleted_at as journal_deleted', 'transaction_journals.deleted_at as journal_deleted',
'transactions.id as transaction_id', 'transactions.id as transaction_id',
'transactions.deleted_at as transaction_deleted_at'] 'transactions.deleted_at as transaction_deleted_at',]
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
@@ -340,7 +337,7 @@ class VerifyDatabase extends Command
{ {
$plural = str_plural($name); $plural = str_plural($name);
$class = sprintf('FireflyIII\Models\%s', ucfirst($name)); $class = sprintf('FireflyIII\Models\%s', ucfirst($name));
$field = $name === 'tag' ? 'tag' : 'name'; $field = 'tag' === $name ? 'tag' : 'name';
$set = $class::leftJoin($name . '_transaction_journal', $plural . '.id', '=', $name . '_transaction_journal.' . $name . '_id') $set = $class::leftJoin($name . '_transaction_journal', $plural . '.id', '=', $name . '_transaction_journal.' . $name . '_id')
->leftJoin('users', $plural . '.user_id', '=', 'users.id') ->leftJoin('users', $plural . '.user_id', '=', 'users.id')
->distinct() ->distinct()
@@ -380,7 +377,7 @@ class VerifyDatabase extends Command
/** @var User $user */ /** @var User $user */
foreach ($userRepository->all() as $user) { foreach ($userRepository->all() as $user) {
$sum = strval($user->transactions()->sum('amount')); $sum = strval($user->transactions()->sum('amount'));
if (bccomp($sum, '0') !== 0) { if (0 !== bccomp($sum, '0')) {
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!'); $this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
} }
} }
@@ -396,7 +393,7 @@ class VerifyDatabase extends Command
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->get( ->get(
['transactions.id as transaction_id', 'transactions.deleted_at as transaction_deleted', 'transaction_journals.id as journal_id', ['transactions.id as transaction_id', 'transactions.deleted_at as transaction_deleted', 'transaction_journals.id as journal_id',
'transaction_journals.deleted_at'] 'transaction_journals.deleted_at',]
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {

View File

@@ -18,10 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
/** /**
* Kernel.php * Kernel.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -48,13 +46,10 @@ class Kernel extends ConsoleKernel
*/ */
protected $commands protected $commands
= [ = [
//
]; ];
/** /**
* Register the commands for the application. * Register the commands for the application.
*
* @return void
*/ */
protected function commands() protected function commands()
{ {
@@ -68,7 +63,6 @@ class Kernel extends ConsoleKernel
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param \Illuminate\Console\Scheduling\Schedule $schedule
* *
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -28,9 +27,7 @@ use Illuminate\Queue\SerializesModels;
use Log; use Log;
/** /**
* Class AdminRequestedTestMessage * Class AdminRequestedTestMessage.
*
* @package FireflyIII\Events
*/ */
class AdminRequestedTestMessage extends Event class AdminRequestedTestMessage extends Event
{ {

View File

@@ -18,17 +18,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
/** /**
* Class Event * Class Event.
*
* @package FireflyIII\Events
*/ */
abstract class Event abstract class Event
{ {
//
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -27,9 +26,7 @@ use FireflyIII\User;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* Class RegisteredUser * Class RegisteredUser.
*
* @package FireflyIII\Events
*/ */
class RegisteredUser extends Event class RegisteredUser extends Event
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -27,9 +26,7 @@ use FireflyIII\User;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* Class RequestedNewPassword * Class RequestedNewPassword.
*
* @package FireflyIII\Events
*/ */
class RequestedNewPassword extends Event class RequestedNewPassword extends Event
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -27,9 +26,7 @@ use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* Class StoredTransactionJournal * Class StoredTransactionJournal.
*
* @package FireflyIII\Events
*/ */
class StoredTransactionJournal extends Event class StoredTransactionJournal extends Event
{ {
@@ -48,7 +45,6 @@ class StoredTransactionJournal extends Event
*/ */
public function __construct(TransactionJournal $journal, int $piggyBankId) public function __construct(TransactionJournal $journal, int $piggyBankId)
{ {
//
$this->journal = $journal; $this->journal = $journal;
$this->piggyBankId = $piggyBankId; $this->piggyBankId = $piggyBankId;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -27,9 +26,7 @@ use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* Class UpdatedTransactionJournal * Class UpdatedTransactionJournal.
*
* @package FireflyIII\Events
*/ */
class UpdatedTransactionJournal extends Event class UpdatedTransactionJournal extends Event
{ {
@@ -45,7 +42,6 @@ class UpdatedTransactionJournal extends Event
*/ */
public function __construct(TransactionJournal $journal) public function __construct(TransactionJournal $journal)
{ {
//
$this->journal = $journal; $this->journal = $journal;
} }
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -27,9 +26,7 @@ use FireflyIII\User;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* Class UserChangedEmail * Class UserChangedEmail.
*
* @package FireflyIII\Events
*/ */
class UserChangedEmail extends Event class UserChangedEmail extends Event
{ {

View File

@@ -18,15 +18,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;
/** /**
* Class FireflyException * Class FireflyException.
*
* @package FireflyIII\Exceptions
*/ */
class FireflyException extends \Exception class FireflyException extends \Exception
{ {

View File

@@ -18,10 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
/** /**
* Handler.php * Handler.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -58,7 +56,6 @@ class Handler extends ExceptionHandler
*/ */
protected $dontReport protected $dontReport
= [ = [
//
]; ];
/** /**
@@ -86,9 +83,8 @@ class Handler extends ExceptionHandler
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
* @param \Exception $exception
* *
* @return void * @param \Exception $exception
*/ */
public function report(Exception $exception) public function report(Exception $exception)
{ {
@@ -119,7 +115,6 @@ class Handler extends ExceptionHandler
dispatch($job); dispatch($job);
} }
parent::report($exception); parent::report($exception);
} }
} }

View File

@@ -18,15 +18,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;
/** /**
* Class NotImplementedException * Class NotImplementedException.
*
* @package FireflyIII\Exceptions
*/ */
class NotImplementedException extends \Exception class NotImplementedException extends \Exception
{ {

View File

@@ -18,15 +18,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;
/** /**
* Class ValidationExceptions * Class ValidationExceptions.
*
* @package FireflyIII\Exception
*/ */
class ValidationException extends \Exception class ValidationException extends \Exception
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
@@ -33,9 +32,7 @@ use Log;
use Storage; use Storage;
/** /**
* Class AttachmentCollector * Class AttachmentCollector.
*
* @package FireflyIII\Export\Collector
*/ */
class AttachmentCollector extends BasicCollector implements CollectorInterface class AttachmentCollector extends BasicCollector implements CollectorInterface
{ {
@@ -55,7 +52,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
*/ */
public function __construct() public function __construct()
{ {
/** @var AttachmentRepositoryInterface repository */ // @var AttachmentRepositoryInterface repository
$this->repository = app(AttachmentRepositoryInterface::class); $this->repository = app(AttachmentRepositoryInterface::class);
// make storage: // make storage:
$this->uploadDisk = Storage::disk('upload'); $this->uploadDisk = Storage::disk('upload');

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
@@ -28,9 +27,7 @@ use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class BasicCollector * Class BasicCollector.
*
* @package FireflyIII\Export\Collector
*/ */
class BasicCollector class BasicCollector
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
@@ -27,9 +26,7 @@ use FireflyIII\Models\ExportJob;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface CollectorInterface * Interface CollectorInterface.
*
* @package FireflyIII\Export\Collector
*/ */
interface CollectorInterface interface CollectorInterface
{ {
@@ -45,9 +42,6 @@ interface CollectorInterface
/** /**
* @param Collection $entries * @param Collection $entries
*
* @return void
*
*/ */
public function setEntries(Collection $entries); public function setEntries(Collection $entries);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
@@ -30,9 +29,7 @@ use Log;
use Storage; use Storage;
/** /**
* Class UploadCollector * Class UploadCollector.
*
* @package FireflyIII\Export\Collector
*/ */
class UploadCollector extends BasicCollector implements CollectorInterface class UploadCollector extends BasicCollector implements CollectorInterface
{ {
@@ -94,7 +91,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
{ {
// find job associated with import file: // find job associated with import file:
$job = $this->job->user->importJobs()->where('key', $key)->first(); $job = $this->job->user->importJobs()->where('key', $key)->first();
if (is_null($job)) { if (null === $job) {
return false; return false;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Entry; namespace FireflyIII\Export\Entry;
@@ -27,7 +26,7 @@ use FireflyIII\Models\Transaction;
/** /**
* To extend the exported object, in case of new features in Firefly III for example, * To extend the exported object, in case of new features in Firefly III for example,
* do the following: * do the following:.
* *
* - Add the field(s) to this class. If you add more than one related field, add a new object. * - Add the field(s) to this class. If you add more than one related field, add a new object.
* - Make sure the "fromJournal"-routine fills these fields. * - Make sure the "fromJournal"-routine fills these fields.
@@ -39,52 +38,42 @@ use FireflyIII\Models\Transaction;
* *
* *
* Class Entry * Class Entry
*
* @SuppressWarnings(PHPMD.LongVariable) * @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.TooManyFields)
*
* @package FireflyIII\Export\Entry
*/ */
final class Entry final class Entry
{ {
// @formatter:off // @formatter:off
public $journal_id;
public $transaction_id = 0;
public $date;
public $description;
public $currency_code;
public $amount; public $amount;
public $foreign_currency_code = ''; public $asset_account_bic;
public $foreign_amount = '0'; public $asset_account_iban;
public $transaction_type;
public $asset_account_id; public $asset_account_id;
public $asset_account_name; public $asset_account_name;
public $asset_account_iban;
public $asset_account_bic;
public $asset_account_number; public $asset_account_number;
public $asset_currency_code; public $asset_currency_code;
public $opposing_account_id;
public $opposing_account_name;
public $opposing_account_iban;
public $opposing_account_bic;
public $opposing_account_number;
public $opposing_currency_code;
public $budget_id;
public $budget_name;
public $category_id;
public $category_name;
public $bill_id; public $bill_id;
public $bill_name; public $bill_name;
public $budget_id;
public $budget_name;
public $category_id;
public $category_name;
public $currency_code;
public $date;
public $description;
public $foreign_amount = '0';
public $foreign_currency_code = '';
public $journal_id;
public $notes; public $notes;
public $opposing_account_bic;
public $opposing_account_iban;
public $opposing_account_id;
public $opposing_account_name;
public $opposing_account_number;
public $opposing_currency_code;
public $tags; public $tags;
public $transaction_id = 0;
public $transaction_type;
// @formatter:on // @formatter:on
/** /**
@@ -104,7 +93,7 @@ final class Entry
* *
* @return Entry * @return Entry
*/ */
public static function fromTransaction(Transaction $transaction): Entry public static function fromTransaction(Transaction $transaction): self
{ {
$entry = new self; $entry = new self;
$entry->journal_id = $transaction->journal_id; $entry->journal_id = $transaction->journal_id;
@@ -117,8 +106,8 @@ final class Entry
$entry->currency_code = $transaction->transactionCurrency->code; $entry->currency_code = $transaction->transactionCurrency->code;
$entry->amount = round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places); $entry->amount = round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places);
$entry->foreign_currency_code = is_null($transaction->foreign_currency_id) ? null : $transaction->foreignCurrency->code; $entry->foreign_currency_code = null === $transaction->foreign_currency_id ? null : $transaction->foreignCurrency->code;
$entry->foreign_amount = is_null($transaction->foreign_currency_id) $entry->foreign_amount = null === $transaction->foreign_currency_id
? null ? null
: strval( : strval(
round( round(
@@ -142,23 +131,23 @@ final class Entry
$entry->opposing_account_bic = $transaction->opposing_account_bic; $entry->opposing_account_bic = $transaction->opposing_account_bic;
$entry->opposing_currency_code = $transaction->opposing_currency_code; $entry->opposing_currency_code = $transaction->opposing_currency_code;
/** budget */ // budget
$entry->budget_id = $transaction->transaction_budget_id; $entry->budget_id = $transaction->transaction_budget_id;
$entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name); $entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name);
if (is_null($transaction->transaction_budget_id)) { if (null === $transaction->transaction_budget_id) {
$entry->budget_id = $transaction->transaction_journal_budget_id; $entry->budget_id = $transaction->transaction_journal_budget_id;
$entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_journal_budget_name); $entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_journal_budget_name);
} }
/** category */ // category
$entry->category_id = $transaction->transaction_category_id; $entry->category_id = $transaction->transaction_category_id;
$entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name); $entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name);
if (is_null($transaction->transaction_category_id)) { if (null === $transaction->transaction_category_id) {
$entry->category_id = $transaction->transaction_journal_category_id; $entry->category_id = $transaction->transaction_journal_category_id;
$entry->category_name = app('steam')->tryDecrypt($transaction->transaction_journal_category_name); $entry->category_name = app('steam')->tryDecrypt($transaction->transaction_journal_category_name);
} }
/** budget */ // budget
$entry->bill_id = $transaction->bill_id; $entry->bill_id = $transaction->bill_id;
$entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name); $entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export; namespace FireflyIII\Export;
@@ -42,15 +41,12 @@ use Storage;
use ZipArchive; use ZipArchive;
/** /**
* Class ExpandedProcessor * Class ExpandedProcessor.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // its doing a lot. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // its doing a lot.
*
* @package FireflyIII\Export
*/ */
class ExpandedProcessor implements ProcessorInterface class ExpandedProcessor implements ProcessorInterface
{ {
/** @var Collection */ /** @var Collection */
public $accounts; public $accounts;
/** @var string */ /** @var string */
@@ -175,6 +171,7 @@ class ExpandedProcessor implements ProcessorInterface
/** /**
* @return bool * @return bool
*
* @throws FireflyException * @throws FireflyException
*/ */
public function createZipFile(): bool public function createZipFile(): bool
@@ -183,7 +180,7 @@ class ExpandedProcessor implements ProcessorInterface
$file = $this->job->key . '.zip'; $file = $this->job->key . '.zip';
$fullPath = storage_path('export') . '/' . $file; $fullPath = storage_path('export') . '/' . $file;
if ($zip->open($fullPath, ZipArchive::CREATE) !== true) { if (true !== $zip->open($fullPath, ZipArchive::CREATE)) {
throw new FireflyException('Cannot store zip file.'); throw new FireflyException('Cannot store zip file.');
} }
// for each file in the collection, add it to the zip file. // for each file in the collection, add it to the zip file.
@@ -278,7 +275,7 @@ class ExpandedProcessor implements ProcessorInterface
} }
/** /**
* Get all IBAN / SWIFT / account numbers * Get all IBAN / SWIFT / account numbers.
* *
* @param array $array * @param array $array
* *

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;
@@ -27,9 +26,7 @@ use FireflyIII\Models\ExportJob;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class BasicExporter * Class BasicExporter.
*
* @package FireflyIII\Export\Exporter
*/ */
class BasicExporter class BasicExporter
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;
@@ -28,9 +27,7 @@ use League\Csv\Writer;
use SplFileObject; use SplFileObject;
/** /**
* Class CsvExporter * Class CsvExporter.
*
* @package FireflyIII\Export\Exporter
*/ */
class CsvExporter extends BasicExporter implements ExporterInterface class CsvExporter extends BasicExporter implements ExporterInterface
{ {
@@ -69,7 +66,7 @@ class CsvExporter extends BasicExporter implements ExporterInterface
// get field names for header row: // get field names for header row:
$first = $this->getEntries()->first(); $first = $this->getEntries()->first();
$headers = []; $headers = [];
if (!is_null($first)) { if (null !== $first) {
$headers = array_keys(get_object_vars($first)); $headers = array_keys(get_object_vars($first));
} }
@@ -88,7 +85,6 @@ class CsvExporter extends BasicExporter implements ExporterInterface
return true; return true;
} }
private function tempFile() private function tempFile()
{ {
$this->fileName = $this->job->key . '-records.csv'; $this->fileName = $this->job->key . '-records.csv';

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;
@@ -27,9 +26,7 @@ use FireflyIII\Models\ExportJob;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface ExporterInterface * Interface ExporterInterface.
*
* @package FireflyIII\Export\Exporter
*/ */
interface ExporterInterface interface ExporterInterface
{ {
@@ -50,9 +47,6 @@ interface ExporterInterface
/** /**
* @param Collection $entries * @param Collection $entries
*
* @return void
*
*/ */
public function setEntries(Collection $entries); public function setEntries(Collection $entries);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Export; namespace FireflyIII\Export;
@@ -26,13 +25,10 @@ namespace FireflyIII\Export;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface ProcessorInterface * Interface ProcessorInterface.
*
* @package FireflyIII\Export
*/ */
interface ProcessorInterface interface ProcessorInterface
{ {
/** /**
* Processor constructor. * Processor constructor.
*/ */

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Chart\Basic; namespace FireflyIII\Generator\Chart\Basic;
@@ -27,15 +26,12 @@ use FireflyIII\Support\ChartColour;
use Steam; use Steam;
/** /**
* Class ChartJsGenerator * Class ChartJsGenerator.
*
* @package FireflyIII\Generator\Chart\Basic
*/ */
class ChartJsGenerator implements GeneratorInterface class ChartJsGenerator implements GeneratorInterface
{ {
/** /**
* Will generate a Chart JS compatible array from the given input. Expects this format * Will generate a Chart JS compatible array from the given input. Expects this format.
* *
* Will take labels for all from first set. * Will take labels for all from first set.
* *
@@ -102,7 +98,7 @@ class ChartJsGenerator implements GeneratorInterface
} }
/** /**
* Expects data as: * Expects data as:.
* *
* key => value * key => value
* *
@@ -123,7 +119,7 @@ class ChartJsGenerator implements GeneratorInterface
// different sort when values are positive and when they're negative. // different sort when values are positive and when they're negative.
asort($data); asort($data);
$next = next($data); $next = next($data);
if (!is_bool($next) && bccomp($next, '0') === 1) { if (!is_bool($next) && 1 === bccomp($next, '0')) {
// next is positive, sort other way around. // next is positive, sort other way around.
arsort($data); arsort($data);
} }
@@ -131,19 +127,18 @@ class ChartJsGenerator implements GeneratorInterface
$index = 0; $index = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
// make larger than 0 // make larger than 0
$chartData['datasets'][0]['data'][] = floatval(Steam::positive($value)); $chartData['datasets'][0]['data'][] = floatval(Steam::positive($value));
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index); $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$chartData['labels'][] = $key; $chartData['labels'][] = $key;
$index++; ++$index;
} }
return $chartData; return $chartData;
} }
/** /**
* Will generate a (ChartJS) compatible array from the given input. Expects this format: * Will generate a (ChartJS) compatible array from the given input. Expects this format:.
* *
* 'label-of-entry' => value * 'label-of-entry' => value
* 'label-of-entry' => value * 'label-of-entry' => value

View File

@@ -18,21 +18,17 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Chart\Basic; namespace FireflyIII\Generator\Chart\Basic;
/** /**
* Interface GeneratorInterface * Interface GeneratorInterface.
*
* @package FireflyIII\Generator\Chart\Basic
*/ */
interface GeneratorInterface interface GeneratorInterface
{ {
/** /**
* Will generate a Chart JS compatible array from the given input. Expects this format * Will generate a Chart JS compatible array from the given input. Expects this format.
* *
* Will take labels for all from first set. * Will take labels for all from first set.
* *
@@ -66,7 +62,7 @@ interface GeneratorInterface
public function multiSet(array $data): array; public function multiSet(array $data): array;
/** /**
* Expects data as: * Expects data as:.
* *
* key => value * key => value
* *
@@ -77,7 +73,7 @@ interface GeneratorInterface
public function pieChart(array $data): array; public function pieChart(array $data): array;
/** /**
* Will generate a (ChartJS) compatible array from the given input. Expects this format: * Will generate a (ChartJS) compatible array from the given input. Expects this format:.
* *
* 'label-of-entry' => value * 'label-of-entry' => value
* 'label-of-entry' => value * 'label-of-entry' => value

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Audit; namespace FireflyIII\Generator\Report\Audit;
@@ -27,15 +26,12 @@ use Carbon\Carbon;
use FireflyIII\Generator\Report\ReportGeneratorInterface; use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Steam; use Steam;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator.
*
* @package FireflyIII\Generator\Report\Audit
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
@@ -74,7 +70,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
'create_date', 'update_date', 'create_date', 'update_date',
]; ];
return view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow')) return view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts) ->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
->render(); ->render();
@@ -153,7 +148,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long
*
*/ */
private function getAuditReport(Account $account, Carbon $date): array private function getAuditReport(Account $account, Carbon $date): array
{ {
@@ -169,7 +163,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$startBalance = $dayBeforeBalance; $startBalance = $dayBeforeBalance;
$currency = $currencyRepos->find(intval($account->getMeta('currency_id'))); $currency = $currencyRepos->find(intval($account->getMeta('currency_id')));
/** @var Transaction $journal */ // @var Transaction $journal
foreach ($journals as $transaction) { foreach ($journals as $transaction) {
$transaction->before = $startBalance; $transaction->before = $startBalance;
$transactionAmount = $transaction->transaction_amount; $transactionAmount = $transaction->transaction_amount;

View File

@@ -18,19 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Audit; namespace FireflyIII\Generator\Report\Audit;
/** /**
* Class MultiYearReportGenerator * Class MultiYearReportGenerator.
*
* @package FireflyIII\Generator\Report\Audit
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
/** // Doesn't do anything different.
* Doesn't do anything different.
*/
} }

View File

@@ -18,20 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Audit; namespace FireflyIII\Generator\Report\Audit;
/** /**
* Class YearReportGenerator * Class YearReportGenerator.
*
* @package FireflyIII\Generator\Report\Audit
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
/**
* Doesn't do anything different.
*/
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Budget; namespace FireflyIII\Generator\Report\Budget;
@@ -36,9 +35,7 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator.
*
* @package FireflyIII\Generator\Report\Budget
*/ */
class MonthReportGenerator extends Support implements ReportGeneratorInterface class MonthReportGenerator extends Support implements ReportGeneratorInterface
{ {

View File

@@ -18,19 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Budget; namespace FireflyIII\Generator\Report\Budget;
/** /**
* Class MultiYearReportGenerator * Class MultiYearReportGenerator.
*
* @package FireflyIII\Generator\Report\Budget
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
/** // Doesn't do anything different.
* Doesn't do anything different.
*/
} }

View File

@@ -18,20 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Budget; namespace FireflyIII\Generator\Report\Budget;
/** /**
* Class YearReportGenerator * Class YearReportGenerator.
*
* @package FireflyIII\Generator\Report\Budget
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
/**
* Doesn't do anything different.
*/
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Category; namespace FireflyIII\Generator\Report\Category;
@@ -37,9 +36,7 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator.
*
* @package FireflyIII\Generator\Report\Category
*/ */
class MonthReportGenerator extends Support implements ReportGeneratorInterface class MonthReportGenerator extends Support implements ReportGeneratorInterface
{ {
@@ -82,7 +79,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topExpenses = $this->getTopExpenses(); $topExpenses = $this->getTopExpenses();
$topIncome = $this->getTopIncome(); $topIncome = $this->getTopIncome();
// render! // render!
return view( return view(
'reports.category.month', 'reports.category.month',

View File

@@ -18,19 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Category; namespace FireflyIII\Generator\Report\Category;
/** /**
* Class MultiYearReportGenerator * Class MultiYearReportGenerator.
*
* @package FireflyIII\Generator\Report\Category
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
/** // Doesn't do anything different.
* Doesn't do anything different.
*/
} }

View File

@@ -18,20 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Category; namespace FireflyIII\Generator\Report\Category;
/** /**
* Class YearReportGenerator * Class YearReportGenerator.
*
* @package FireflyIII\Generator\Report\Category
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
/**
* Doesn't do anything different.
*/
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report; namespace FireflyIII\Generator\Report;
@@ -27,19 +26,17 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
/** /**
* Class ReportGeneratorFactory * Class ReportGeneratorFactory.
*
* @package FireflyIII\Generator\Report
*/ */
class ReportGeneratorFactory class ReportGeneratorFactory
{ {
/** /**
* @param string $type * @param string $type
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
*
* @throws FireflyException * @throws FireflyException
*/ */
public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface
@@ -55,7 +52,6 @@ class ReportGeneratorFactory
$period = 'MultiYear'; $period = 'MultiYear';
} }
$class = sprintf('FireflyIII\Generator\Report\%s\%sReportGenerator', $type, $period); $class = sprintf('FireflyIII\Generator\Report\%s\%sReportGenerator', $type, $period);
if (class_exists($class)) { if (class_exists($class)) {
/** @var ReportGeneratorInterface $obj */ /** @var ReportGeneratorInterface $obj */

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report; namespace FireflyIII\Generator\Report;
@@ -27,9 +26,7 @@ use Carbon\Carbon;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface ReportGeneratorInterface * Interface ReportGeneratorInterface.
*
* @package FireflyIII\Generator\Report
*/ */
interface ReportGeneratorInterface interface ReportGeneratorInterface
{ {
@@ -43,40 +40,40 @@ interface ReportGeneratorInterface
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
*/ */
public function setAccounts(Collection $accounts): ReportGeneratorInterface; public function setAccounts(Collection $accounts): self;
/** /**
* @param Collection $budgets * @param Collection $budgets
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
*/ */
public function setBudgets(Collection $budgets): ReportGeneratorInterface; public function setBudgets(Collection $budgets): self;
/** /**
* @param Collection $categories * @param Collection $categories
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
*/ */
public function setCategories(Collection $categories): ReportGeneratorInterface; public function setCategories(Collection $categories): self;
/** /**
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
*/ */
public function setEndDate(Carbon $date): ReportGeneratorInterface; public function setEndDate(Carbon $date): self;
/** /**
* @param Carbon $date * @param Carbon $date
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
*/ */
public function setStartDate(Carbon $date): ReportGeneratorInterface; public function setStartDate(Carbon $date): self;
/** /**
* @param Collection $tags * @param Collection $tags
* *
* @return ReportGeneratorInterface * @return ReportGeneratorInterface
*/ */
public function setTags(Collection $tags): ReportGeneratorInterface; public function setTags(Collection $tags): self;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Standard; namespace FireflyIII\Generator\Report\Standard;
@@ -29,9 +28,7 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator.
*
* @package FireflyIII\Generator\Report\Standard
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Standard; namespace FireflyIII\Generator\Report\Standard;
@@ -28,9 +27,7 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator.
*
* @package FireflyIII\Generator\Report\Standard
*/ */
class MultiYearReportGenerator implements ReportGeneratorInterface class MultiYearReportGenerator implements ReportGeneratorInterface
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Standard; namespace FireflyIII\Generator\Report\Standard;
@@ -28,9 +27,7 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator.
*
* @package FireflyIII\Generator\Report\Standard
*/ */
class YearReportGenerator implements ReportGeneratorInterface class YearReportGenerator implements ReportGeneratorInterface
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report; namespace FireflyIII\Generator\Report;
@@ -27,9 +26,7 @@ use FireflyIII\Models\Transaction;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class Support * Class Support.
*
* @package FireflyIII\Generator\Report\Category
*/ */
class Support class Support
{ {
@@ -79,7 +76,7 @@ class Support
]; ];
continue; continue;
} }
$result[$opposingId]['count']++; ++$result[$opposingId]['count'];
$result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount); $result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount);
$result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], strval($result[$opposingId]['count'])); $result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], strval($result[$opposingId]['count']));
} }
@@ -97,6 +94,7 @@ class Support
/** /**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
*
* @param array $spent * @param array $spent
* @param array $earned * @param array $earned
* *
@@ -107,7 +105,7 @@ class Support
$return = []; $return = [];
/** /**
* @var int $accountId * @var int
* @var string $entry * @var string $entry
*/ */
foreach ($spent as $objectId => $entry) { foreach ($spent as $objectId => $entry) {
@@ -120,7 +118,7 @@ class Support
unset($entry); unset($entry);
/** /**
* @var int $accountId * @var int
* @var string $entry * @var string $entry
*/ */
foreach ($earned as $objectId => $entry) { foreach ($earned as $objectId => $entry) {
@@ -131,7 +129,6 @@ class Support
$return[$objectId]['earned'] = $entry; $return[$objectId]['earned'] = $entry;
} }
return $return; return $return;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Tag; namespace FireflyIII\Generator\Report\Tag;
@@ -38,13 +37,10 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class MonthReportGenerator * Class MonthReportGenerator.
*
* @package FireflyIII\Generator\Report\Tag
*/ */
class MonthReportGenerator extends Support implements ReportGeneratorInterface class MonthReportGenerator extends Support implements ReportGeneratorInterface
{ {
/** @var Collection */ /** @var Collection */
private $accounts; private $accounts;
/** @var Carbon */ /** @var Carbon */
@@ -84,7 +80,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$topExpenses = $this->getTopExpenses(); $topExpenses = $this->getTopExpenses();
$topIncome = $this->getTopIncome(); $topIncome = $this->getTopIncome();
// render! // render!
return view( return view(
'reports.tag.month', 'reports.tag.month',

View File

@@ -18,19 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Tag; namespace FireflyIII\Generator\Report\Tag;
/** /**
* Class MultiYearReportGenerator * Class MultiYearReportGenerator.
*
* @package FireflyIII\Generator\Report\Tag
*/ */
class MultiYearReportGenerator extends MonthReportGenerator class MultiYearReportGenerator extends MonthReportGenerator
{ {
/** // Doesn't do anything different.
* Doesn't do anything different.
*/
} }

View File

@@ -18,20 +18,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Generator\Report\Tag; namespace FireflyIII\Generator\Report\Tag;
/** /**
* Class YearReportGenerator * Class YearReportGenerator.
*
* @package FireflyIII\Generator\Report\Tag
*/ */
class YearReportGenerator extends MonthReportGenerator class YearReportGenerator extends MonthReportGenerator
{ {
// Doesn't do anything different.
/**
* Doesn't do anything different.
*/
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
@@ -31,9 +30,7 @@ use Session;
use Swift_TransportException; use Swift_TransportException;
/** /**
* Class AdminEventHandler * Class AdminEventHandler.
*
* @package FireflyIII\Handlers\Events
*/ */
class AdminEventHandler class AdminEventHandler
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
@@ -37,8 +36,6 @@ use Log;
* @codeCoverageIgnore * @codeCoverageIgnore
* *
* Class StoredJournalEventHandler * Class StoredJournalEventHandler
*
* @package FireflyIII\Handlers\Events
*/ */
class StoredJournalEventHandler class StoredJournalEventHandler
{ {
@@ -88,7 +85,7 @@ class StoredJournalEventHandler
} }
// piggy exists? // piggy exists?
if (is_null($piggyBank->id)) { if (null === $piggyBank->id) {
Log::error(sprintf('There is no piggy bank with ID #%d', $piggyBankId)); Log::error(sprintf('There is no piggy bank with ID #%d', $piggyBankId));
return true; return true;
@@ -96,7 +93,7 @@ class StoredJournalEventHandler
// repetition exists? // repetition exists?
$repetition = $this->repository->getRepetition($piggyBank, $journal->date); $repetition = $this->repository->getRepetition($piggyBank, $journal->date);
if (is_null($repetition->id)) { if (null === $repetition->id) {
Log::error(sprintf('No piggy bank repetition on %s!', $journal->date->format('Y-m-d'))); Log::error(sprintf('No piggy bank repetition on %s!', $journal->date->format('Y-m-d')));
return true; return true;
@@ -104,7 +101,7 @@ class StoredJournalEventHandler
// get the amount // get the amount
$amount = $this->repository->getExactAmount($piggyBank, $repetition, $journal); $amount = $this->repository->getExactAmount($piggyBank, $repetition, $journal);
if (bccomp($amount, '0') === 0) { if (0 === bccomp($amount, '0')) {
Log::debug('Amount is zero, will not create event.'); Log::debug('Amount is zero, will not create event.');
return true; return true;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
@@ -34,8 +33,6 @@ use FireflyIII\TransactionRules\Processor;
* @codeCoverageIgnore * @codeCoverageIgnore
* *
* Class UpdatedJournalEventHandler * Class UpdatedJournalEventHandler
*
* @package FireflyIII\Handlers\Events
*/ */
class UpdatedJournalEventHandler class UpdatedJournalEventHandler
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
@@ -37,17 +36,14 @@ use Preferences;
use Swift_TransportException; use Swift_TransportException;
/** /**
* Class UserEventHandler * Class UserEventHandler.
* *
* This class responds to any events that have anything to do with the User object. * This class responds to any events that have anything to do with the User object.
* *
* The method name reflects what is being done. This is in the present tense. * The method name reflects what is being done. This is in the present tense.
*
* @package FireflyIII\Handlers\Events
*/ */
class UserEventHandler class UserEventHandler
{ {
/** /**
* This method will bestow upon a user the "owner" role if he is the first user in the system. * This method will bestow upon a user the "owner" role if he is the first user in the system.
* *
@@ -61,7 +57,7 @@ class UserEventHandler
$repository = app(UserRepositoryInterface::class); $repository = app(UserRepositoryInterface::class);
// first user ever? // first user ever?
if ($repository->count() === 1) { if (1 === $repository->count()) {
$repository->attachRole($event->user, 'owner'); $repository->attachRole($event->user, 'owner');
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Attachments; namespace FireflyIII\Helpers\Attachments;
@@ -33,13 +32,10 @@ use Storage;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
/** /**
* Class AttachmentHelper * Class AttachmentHelper.
*
* @package FireflyIII\Helpers\Attachments
*/ */
class AttachmentHelper implements AttachmentHelperInterface class AttachmentHelper implements AttachmentHelperInterface
{ {
/** @var Collection */ /** @var Collection */
public $attachments; public $attachments;
/** @var MessageBag */ /** @var MessageBag */
@@ -114,7 +110,7 @@ class AttachmentHelper implements AttachmentHelperInterface
if (is_array($files)) { if (is_array($files)) {
/** @var UploadedFile $entry */ /** @var UploadedFile $entry */
foreach ($files as $entry) { foreach ($files as $entry) {
if (!is_null($entry)) { if (null !== $entry) {
$this->processFile($entry, $model); $this->processFile($entry, $model);
} }
} }
@@ -152,7 +148,6 @@ class AttachmentHelper implements AttachmentHelperInterface
} }
/** /**
*
* @param UploadedFile $file * @param UploadedFile $file
* @param Model $model * @param Model $model
* *
@@ -161,7 +156,7 @@ class AttachmentHelper implements AttachmentHelperInterface
protected function processFile(UploadedFile $file, Model $model): Attachment protected function processFile(UploadedFile $file, Model $model): Attachment
{ {
$validation = $this->validateUpload($file, $model); $validation = $this->validateUpload($file, $model);
if ($validation === false) { if (false === $validation) {
return new Attachment; return new Attachment;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Attachments; namespace FireflyIII\Helpers\Attachments;
@@ -29,13 +28,10 @@ use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
/** /**
* Interface AttachmentHelperInterface * Interface AttachmentHelperInterface.
*
* @package FireflyIII\Helpers\Attachments
*/ */
interface AttachmentHelperInterface interface AttachmentHelperInterface
{ {
/** /**
* @param Attachment $attachment * @param Attachment $attachment
* *
@@ -60,7 +56,6 @@ interface AttachmentHelperInterface
/** /**
* @param Model $model * @param Model $model
*
* @param null|array $files * @param null|array $files
* *
* @return bool * @return bool

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Chart; namespace FireflyIII\Helpers\Chart;
@@ -41,11 +40,7 @@ use Illuminate\Support\Collection;
use Steam; use Steam;
/** /**
* Class MetaPieChart * Class MetaPieChart.
*
* @package FireflyIII\Helpers\Chart
*
*
*/ */
class MetaPieChart implements MetaPieChartInterface class MetaPieChart implements MetaPieChartInterface
{ {
@@ -108,7 +103,7 @@ class MetaPieChart implements MetaPieChartInterface
$key = strval(trans('firefly.everything_else')); $key = strval(trans('firefly.everything_else'));
// also collect all other transactions // also collect all other transactions
if ($this->collectOtherObjects && $direction === 'expense') { if ($this->collectOtherObjects && 'expense' === $direction) {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user); $collector->setUser($this->user);
@@ -121,7 +116,7 @@ class MetaPieChart implements MetaPieChartInterface
$chartData[$key] = $sum; $chartData[$key] = $sum;
} }
if ($this->collectOtherObjects && $direction === 'income') { if ($this->collectOtherObjects && 'income' === $direction) {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user); $collector->setUser($this->user);
@@ -258,7 +253,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$types = [TransactionType::DEPOSIT, TransactionType::TRANSFER]; $types = [TransactionType::DEPOSIT, TransactionType::TRANSFER];
$collector->addFilter(NegativeAmountFilter::class); $collector->addFilter(NegativeAmountFilter::class);
if ($direction === 'expense') { if ('expense' === $direction) {
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER]; $types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
$collector->addFilter(PositiveAmountFilter::class); $collector->addFilter(PositiveAmountFilter::class);
$collector->removeFilter(NegativeAmountFilter::class); $collector->removeFilter(NegativeAmountFilter::class);
@@ -271,7 +266,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->withOpposingAccount(); $collector->withOpposingAccount();
$collector->addFilter(OpposingAccountFilter::class); $collector->addFilter(OpposingAccountFilter::class);
if ($direction === 'income') { if ('income' === $direction) {
$collector->removeFilter(TransferFilter::class); $collector->removeFilter(TransferFilter::class);
} }
@@ -294,11 +289,10 @@ class MetaPieChart implements MetaPieChartInterface
* @return array * @return array
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
*/ */
protected function groupByFields(Collection $set, array $fields): array protected function groupByFields(Collection $set, array $fields): array
{ {
if (count($fields) === 0 && $this->tags->count() > 0) { if (0 === count($fields) && $this->tags->count() > 0) {
// do a special group on tags: // do a special group on tags:
return $this->groupByTag($set); return $this->groupByTag($set);
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Chart; namespace FireflyIII\Helpers\Chart;
@@ -28,9 +27,7 @@ use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface MetaPieChartInterface * Interface MetaPieChartInterface.
*
* @package FireflyIII\Helpers\Chart
*/ */
interface MetaPieChartInterface interface MetaPieChartInterface
{ {
@@ -47,54 +44,54 @@ interface MetaPieChartInterface
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setAccounts(Collection $accounts): MetaPieChartInterface; public function setAccounts(Collection $accounts): self;
/** /**
* @param Collection $budgets * @param Collection $budgets
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setBudgets(Collection $budgets): MetaPieChartInterface; public function setBudgets(Collection $budgets): self;
/** /**
* @param Collection $categories * @param Collection $categories
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setCategories(Collection $categories): MetaPieChartInterface; public function setCategories(Collection $categories): self;
/** /**
* @param bool $collectOtherObjects * @param bool $collectOtherObjects
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setCollectOtherObjects(bool $collectOtherObjects): MetaPieChartInterface; public function setCollectOtherObjects(bool $collectOtherObjects): self;
/** /**
* @param Carbon $end * @param Carbon $end
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setEnd(Carbon $end): MetaPieChartInterface; public function setEnd(Carbon $end): self;
/** /**
* @param Carbon $start * @param Carbon $start
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setStart(Carbon $start): MetaPieChartInterface; public function setStart(Carbon $start): self;
/** /**
* @param Collection $tags * @param Collection $tags
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setTags(Collection $tags): MetaPieChartInterface; public function setTags(Collection $tags): self;
/** /**
* @param User $user * @param User $user
* *
* @return MetaPieChartInterface * @return MetaPieChartInterface
*/ */
public function setUser(User $user): MetaPieChartInterface; public function setUser(User $user): self;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collection; namespace FireflyIII\Helpers\Collection;
@@ -26,14 +25,10 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* * Class Balance.
* Class Balance
*
* @package FireflyIII\Helpers\Collection
*/ */
class Balance class Balance
{ {
/** @var BalanceHeader */ /** @var BalanceHeader */
protected $balanceHeader; protected $balanceHeader;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collection; namespace FireflyIII\Helpers\Collection;
@@ -26,15 +25,10 @@ namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Account as AccountModel; use FireflyIII\Models\Account as AccountModel;
/** /**
* * Class BalanceEntry.
* Class BalanceEntry
*
* @package FireflyIII\Helpers\Collection
*/ */
class BalanceEntry class BalanceEntry
{ {
/** @var AccountModel */ /** @var AccountModel */
protected $account; protected $account;
/** @var string */ /** @var string */

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collection; namespace FireflyIII\Helpers\Collection;
@@ -27,14 +26,10 @@ use FireflyIII\Models\Account as AccountModel;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* * Class BalanceHeader.
* Class BalanceHeader
*
* @package FireflyIII\Helpers\Collection
*/ */
class BalanceHeader class BalanceHeader
{ {
/** @var Collection */ /** @var Collection */
protected $accounts; protected $accounts;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collection; namespace FireflyIII\Helpers\Collection;
@@ -29,10 +28,7 @@ use FireflyIII\Models\BudgetLimit;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* * Class BalanceLine.
* Class BalanceLine
*
* @package FireflyIII\Helpers\Collection
*/ */
class BalanceLine class BalanceLine
{ {
@@ -148,20 +144,21 @@ class BalanceLine
/** /**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
* @return string * @return string
*/ */
public function getTitle(): string public function getTitle(): string
{ {
if ($this->getBudget() instanceof BudgetModel && !is_null($this->getBudget()->id)) { if ($this->getBudget() instanceof BudgetModel && null !== $this->getBudget()->id) {
return $this->getBudget()->name; return $this->getBudget()->name;
} }
if ($this->getRole() === self::ROLE_DEFAULTROLE) { if (self::ROLE_DEFAULTROLE === $this->getRole()) {
return strval(trans('firefly.no_budget')); return strval(trans('firefly.no_budget'));
} }
if ($this->getRole() === self::ROLE_TAGROLE) { if (self::ROLE_TAGROLE === $this->getRole()) {
return strval(trans('firefly.coveredWithTags')); return strval(trans('firefly.coveredWithTags'));
} }
if ($this->getRole() === self::ROLE_DIFFROLE) { if (self::ROLE_DIFFROLE === $this->getRole()) {
return strval(trans('firefly.leftUnbalanced')); return strval(trans('firefly.leftUnbalanced'));
} }
@@ -172,7 +169,7 @@ class BalanceLine
* If a BalanceLine has a budget/repetition, each BalanceEntry in this BalanceLine * If a BalanceLine has a budget/repetition, each BalanceEntry in this BalanceLine
* should have a "spent" value, which is the amount of money that has been spent * should have a "spent" value, which is the amount of money that has been spent
* on the given budget/repetition. If you subtract all those amounts from the budget/repetition's * on the given budget/repetition. If you subtract all those amounts from the budget/repetition's
* total amount, this is returned: * total amount, this is returned:.
* *
* @return string * @return string
*/ */

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collection; namespace FireflyIII\Helpers\Collection;
@@ -29,13 +28,10 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class Bill * Class Bill.
*
* @package FireflyIII\Helpers\Collection
*/ */
class Bill class Bill
{ {
/** /**
* @var Collection * @var Collection
*/ */
@@ -105,14 +101,13 @@ class Bill
{ {
$set = $this->bills->sortBy( $set = $this->bills->sortBy(
function (BillLine $bill) { function (BillLine $bill) {
$active = intval($bill->getBill()->active) === 0 ? 1 : 0; $active = 0 === intval($bill->getBill()->active) ? 1 : 0;
$name = $bill->getBill()->name; $name = $bill->getBill()->name;
return $active . $name; return $active . $name;
} }
); );
return $set; return $set;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collection; namespace FireflyIII\Helpers\Collection;
@@ -27,14 +26,10 @@ use Carbon\Carbon;
use FireflyIII\Models\Bill as BillModel; use FireflyIII\Models\Bill as BillModel;
/** /**
* * Class BillLine.
* Class BillLine
*
* @package FireflyIII\Helpers\Collection
*/ */
class BillLine class BillLine
{ {
/** @var string */ /** @var string */
protected $amount; protected $amount;
/** @var BillModel */ /** @var BillModel */
@@ -159,7 +154,7 @@ class BillLine
*/ */
public function isActive(): bool public function isActive(): bool
{ {
return intval($this->bill->active) === 1; return 1 === intval($this->bill->active);
} }
/** /**

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collection; namespace FireflyIII\Helpers\Collection;
@@ -27,14 +26,10 @@ use FireflyIII\Models\Category as CategoryModel;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* * Class Category.
* Class Category
*
* @package FireflyIII\Helpers\Collection
*/ */
class Category class Category
{ {
/** @var Collection */ /** @var Collection */
protected $categories; protected $categories;
/** @var string */ /** @var string */
@@ -79,7 +74,6 @@ class Category
} }
); );
return $set; return $set;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collector; namespace FireflyIII\Helpers\Collector;
@@ -51,7 +50,6 @@ use Steam;
* *
* Class JournalCollector * Class JournalCollector
* *
* @package FireflyIII\Helpers\Collector
* *
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -59,7 +57,6 @@ use Steam;
*/ */
class JournalCollector implements JournalCollectorInterface class JournalCollector implements JournalCollectorInterface
{ {
/** @var array */ /** @var array */
private $accountIds = []; private $accountIds = [];
/** @var int */ /** @var int */
@@ -101,7 +98,6 @@ class JournalCollector implements JournalCollectorInterface
'accounts.encrypted as account_encrypted', 'accounts.encrypted as account_encrypted',
'accounts.iban as account_iban', 'accounts.iban as account_iban',
'account_types.type as account_type', 'account_types.type as account_type',
]; ];
/** @var array */ /** @var array */
private $filters = [InternalTransferFilter::class]; private $filters = [InternalTransferFilter::class];
@@ -218,11 +214,12 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* @return int * @return int
*
* @throws FireflyException * @throws FireflyException
*/ */
public function count(): int public function count(): int
{ {
if ($this->run === true) { if (true === $this->run) {
throw new FireflyException('Cannot count after run in JournalCollector.'); throw new FireflyException('Cannot count after run in JournalCollector.');
} }
@@ -258,7 +255,7 @@ class JournalCollector implements JournalCollectorInterface
$transaction->date = new Carbon($transaction->date); $transaction->date = new Carbon($transaction->date);
$transaction->description = Steam::decrypt(intval($transaction->encrypted), $transaction->description); $transaction->description = Steam::decrypt(intval($transaction->encrypted), $transaction->description);
if (!is_null($transaction->bill_name)) { if (null !== $transaction->bill_name) {
$transaction->bill_name = Steam::decrypt(intval($transaction->bill_name_encrypted), $transaction->bill_name); $transaction->bill_name = Steam::decrypt(intval($transaction->bill_name_encrypted), $transaction->bill_name);
} }
$transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name); $transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name);
@@ -272,11 +269,12 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* @return LengthAwarePaginator * @return LengthAwarePaginator
*
* @throws FireflyException * @throws FireflyException
*/ */
public function getPaginatedJournals(): LengthAwarePaginator public function getPaginatedJournals(): LengthAwarePaginator
{ {
if ($this->run === true) { if (true === $this->run) {
throw new FireflyException('Cannot getPaginatedJournals after run in JournalCollector.'); throw new FireflyException('Cannot getPaginatedJournals after run in JournalCollector.');
} }
$this->count(); $this->count();
@@ -294,7 +292,7 @@ class JournalCollector implements JournalCollectorInterface
public function removeFilter(string $filter): JournalCollectorInterface public function removeFilter(string $filter): JournalCollectorInterface
{ {
$key = array_search($filter, $this->filters, true); $key = array_search($filter, $this->filters, true);
if (!($key === false)) { if (!(false === $key)) {
Log::debug(sprintf('Removed filter %s', $filter)); Log::debug(sprintf('Removed filter %s', $filter));
unset($this->filters[$key]); unset($this->filters[$key]);
} }
@@ -320,7 +318,6 @@ class JournalCollector implements JournalCollectorInterface
$this->addFilter(TransferFilter::class); $this->addFilter(TransferFilter::class);
} }
return $this; return $this;
} }
@@ -416,7 +413,7 @@ class JournalCollector implements JournalCollectorInterface
public function setBudgets(Collection $budgets): JournalCollectorInterface public function setBudgets(Collection $budgets): JournalCollectorInterface
{ {
$budgetIds = $budgets->pluck('id')->toArray(); $budgetIds = $budgets->pluck('id')->toArray();
if (count($budgetIds) === 0) { if (0 === count($budgetIds)) {
return $this; return $this;
} }
$this->joinBudgetTables(); $this->joinBudgetTables();
@@ -440,7 +437,7 @@ class JournalCollector implements JournalCollectorInterface
public function setCategories(Collection $categories): JournalCollectorInterface public function setCategories(Collection $categories): JournalCollectorInterface
{ {
$categoryIds = $categories->pluck('id')->toArray(); $categoryIds = $categories->pluck('id')->toArray();
if (count($categoryIds) === 0) { if (0 === count($categoryIds)) {
return $this; return $this;
} }
$this->joinCategoryTables(); $this->joinCategoryTables();
@@ -514,11 +511,11 @@ class JournalCollector implements JournalCollectorInterface
$this->page = $page; $this->page = $page;
if ($page > 0) { if ($page > 0) {
$page--; --$page;
} }
Log::debug(sprintf('Page is %d', $page)); Log::debug(sprintf('Page is %d', $page));
if (!is_null($this->limit)) { if (null !== $this->limit) {
$offset = ($this->limit * $page); $offset = ($this->limit * $page);
$this->offset = $offset; $this->offset = $offset;
$this->query->skip($offset); $this->query->skip($offset);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Collector; namespace FireflyIII\Helpers\Collector;
@@ -32,9 +31,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface JournalCollectorInterface * Interface JournalCollectorInterface.
*
* @package FireflyIII\Helpers\Collector
*/ */
interface JournalCollectorInterface interface JournalCollectorInterface
{ {
@@ -43,28 +40,28 @@ interface JournalCollectorInterface
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function addFilter(string $filter): JournalCollectorInterface; public function addFilter(string $filter): self;
/** /**
* @param string $amount * @param string $amount
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function amountIs(string $amount): JournalCollectorInterface; public function amountIs(string $amount): self;
/** /**
* @param string $amount * @param string $amount
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function amountLess(string $amount): JournalCollectorInterface; public function amountLess(string $amount): self;
/** /**
* @param string $amount * @param string $amount
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function amountMore(string $amount): JournalCollectorInterface; public function amountMore(string $amount): self;
/** /**
* @return int * @return int
@@ -86,89 +83,89 @@ interface JournalCollectorInterface
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function removeFilter(string $filter): JournalCollectorInterface; public function removeFilter(string $filter): self;
/** /**
* @param Collection $accounts * @param Collection $accounts
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setAccounts(Collection $accounts): JournalCollectorInterface; public function setAccounts(Collection $accounts): self;
/** /**
* @param Carbon $after * @param Carbon $after
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setAfter(Carbon $after): JournalCollectorInterface; public function setAfter(Carbon $after): self;
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setAllAssetAccounts(): JournalCollectorInterface; public function setAllAssetAccounts(): self;
/** /**
* @param Carbon $before * @param Carbon $before
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setBefore(Carbon $before): JournalCollectorInterface; public function setBefore(Carbon $before): self;
/** /**
* @param Collection $bills * @param Collection $bills
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setBills(Collection $bills): JournalCollectorInterface; public function setBills(Collection $bills): self;
/** /**
* @param Budget $budget * @param Budget $budget
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setBudget(Budget $budget): JournalCollectorInterface; public function setBudget(Budget $budget): self;
/** /**
* @param Collection $budgets * @param Collection $budgets
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setBudgets(Collection $budgets): JournalCollectorInterface; public function setBudgets(Collection $budgets): self;
/** /**
* @param Collection $categories * @param Collection $categories
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setCategories(Collection $categories): JournalCollectorInterface; public function setCategories(Collection $categories): self;
/** /**
* @param Category $category * @param Category $category
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setCategory(Category $category): JournalCollectorInterface; public function setCategory(Category $category): self;
/** /**
* @param int $limit * @param int $limit
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setLimit(int $limit): JournalCollectorInterface; public function setLimit(int $limit): self;
/** /**
* @param int $offset * @param int $offset
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setOffset(int $offset): JournalCollectorInterface; public function setOffset(int $offset): self;
/** /**
* @param int $page * @param int $page
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setPage(int $page): JournalCollectorInterface; public function setPage(int $page): self;
/** /**
* @param Carbon $start * @param Carbon $start
@@ -176,28 +173,28 @@ interface JournalCollectorInterface
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setRange(Carbon $start, Carbon $end): JournalCollectorInterface; public function setRange(Carbon $start, Carbon $end): self;
/** /**
* @param Tag $tag * @param Tag $tag
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setTag(Tag $tag): JournalCollectorInterface; public function setTag(Tag $tag): self;
/** /**
* @param Collection $tags * @param Collection $tags
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setTags(Collection $tags): JournalCollectorInterface; public function setTags(Collection $tags): self;
/** /**
* @param array $types * @param array $types
* *
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function setTypes(array $types): JournalCollectorInterface; public function setTypes(array $types): self;
public function setUser(User $user); public function setUser(User $user);
@@ -209,25 +206,25 @@ interface JournalCollectorInterface
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function withBudgetInformation(): JournalCollectorInterface; public function withBudgetInformation(): self;
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function withCategoryInformation(): JournalCollectorInterface; public function withCategoryInformation(): self;
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function withOpposingAccount(): JournalCollectorInterface; public function withOpposingAccount(): self;
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function withoutBudget(): JournalCollectorInterface; public function withoutBudget(): self;
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
public function withoutCategory(): JournalCollectorInterface; public function withoutCategory(): self;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;
@@ -28,12 +27,10 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class AmountFilter * Class AmountFilter.
* *
* This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount * This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount
* ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal. * ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal.
*
* @package FireflyIII\Helpers\Filter
*/ */
class AmountFilter implements FilterInterface class AmountFilter implements FilterInterface
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;
@@ -26,14 +25,10 @@ namespace FireflyIII\Helpers\Filter;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class EmptyFilter * Class EmptyFilter.
*
* @package FireflyIII\Helpers\Filter
*/ */
class EmptyFilter implements FilterInterface class EmptyFilter implements FilterInterface
{ {
/** /**
* @param Collection $set * @param Collection $set
* *

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;
@@ -28,13 +27,11 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class InternalTransferFilter * Class InternalTransferFilter.
* *
* This filter removes any filters that are from A to B or from B to A given a set of * This filter removes any filters that are from A to B or from B to A given a set of
* account id's (in $parameters) where A and B are mentioned. So transfers between the mentioned * account id's (in $parameters) where A and B are mentioned. So transfers between the mentioned
* accounts will be removed. * accounts will be removed.
*
* @package FireflyIII\Helpers\Filter
*/ */
class InternalTransferFilter implements FilterInterface class InternalTransferFilter implements FilterInterface
{ {
@@ -60,7 +57,7 @@ class InternalTransferFilter implements FilterInterface
{ {
return $set->filter( return $set->filter(
function (Transaction $transaction) { function (Transaction $transaction) {
if (is_null($transaction->opposing_account_id)) { if (null === $transaction->opposing_account_id) {
return $transaction; return $transaction;
} }
// both id's in $parameters? // both id's in $parameters?

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;
@@ -28,11 +27,9 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class NegativeAmountFilter * Class NegativeAmountFilter.
* *
* This filter removes entries with a negative amount (the original modifier is -1). * This filter removes entries with a negative amount (the original modifier is -1).
*
* @package FireflyIII\Helpers\Filter
*/ */
class NegativeAmountFilter implements FilterInterface class NegativeAmountFilter implements FilterInterface
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;
@@ -28,12 +27,10 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class OpposingAccountFilter * Class OpposingAccountFilter.
* *
* This filter is similar to the internal transfer filter but only removes transactions when the opposing account is * This filter is similar to the internal transfer filter but only removes transactions when the opposing account is
* amongst $parameters (list of account ID's). * amongst $parameters (list of account ID's).
*
* @package FireflyIII\Helpers\Filter
*/ */
class OpposingAccountFilter implements FilterInterface class OpposingAccountFilter implements FilterInterface
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;
@@ -28,14 +27,12 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class PositiveAmountFilter * Class PositiveAmountFilter.
* *
* This filter removes entries with a negative amount (the original modifier is -1). * This filter removes entries with a negative amount (the original modifier is -1).
* *
* This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount * This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount
* ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal. * ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal.
*
* @package FireflyIII\Helpers\Filter
*/ */
class PositiveAmountFilter implements FilterInterface class PositiveAmountFilter implements FilterInterface
{ {
@@ -49,7 +46,7 @@ class PositiveAmountFilter implements FilterInterface
return $set->filter( return $set->filter(
function (Transaction $transaction) { function (Transaction $transaction) {
// remove by amount // remove by amount
if (bccomp($transaction->transaction_amount, '0') === 1) { if (1 === bccomp($transaction->transaction_amount, '0')) {
Log::debug(sprintf('Filtered #%d because amount is %f.', $transaction->id, $transaction->transaction_amount)); Log::debug(sprintf('Filtered #%d because amount is %f.', $transaction->id, $transaction->transaction_amount));
return null; return null;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Filter; namespace FireflyIII\Helpers\Filter;
@@ -29,11 +28,9 @@ use Illuminate\Support\Collection;
use Steam; use Steam;
/** /**
* Class TransferFilter * Class TransferFilter.
* *
* This filter removes any transfers that are in the collection twice (from A to B and from B to A). * This filter removes any transfers that are in the collection twice (from A to B and from B to A).
*
* @package FireflyIII\Helpers\Filter
*/ */
class TransferFilter implements FilterInterface class TransferFilter implements FilterInterface
{ {
@@ -48,7 +45,7 @@ class TransferFilter implements FilterInterface
$new = new Collection; $new = new Collection;
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($set as $transaction) { foreach ($set as $transaction) {
if ($transaction->transaction_type_type !== TransactionType::TRANSFER) { if (TransactionType::TRANSFER !== $transaction->transaction_type_type) {
$new->push($transaction); $new->push($transaction);
continue; continue;
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers; namespace FireflyIII\Helpers;
@@ -27,20 +26,15 @@ use Carbon\Carbon;
use Preferences; use Preferences;
/** /**
* Class FiscalHelper * Class FiscalHelper.
*
* @package FireflyIII\Helpers
*/ */
class FiscalHelper implements FiscalHelperInterface class FiscalHelper implements FiscalHelperInterface
{ {
/** @var bool */ /** @var bool */
protected $useCustomFiscalYear; protected $useCustomFiscalYear;
/** /**
* FiscalHelper constructor. * FiscalHelper constructor.
*
*
*/ */
public function __construct() public function __construct()
{ {
@@ -56,7 +50,7 @@ class FiscalHelper implements FiscalHelperInterface
{ {
// get start of fiscal year for passed date // get start of fiscal year for passed date
$endDate = $this->startOfFiscalYear($date); $endDate = $this->startOfFiscalYear($date);
if ($this->useCustomFiscalYear === true) { if (true === $this->useCustomFiscalYear) {
// add 1 year and sub 1 day // add 1 year and sub 1 day
$endDate->addYear(); $endDate->addYear();
$endDate->subDay(); $endDate->subDay();
@@ -65,7 +59,6 @@ class FiscalHelper implements FiscalHelperInterface
} }
$endDate->endOfYear(); $endDate->endOfYear();
return $endDate; return $endDate;
} }
@@ -78,7 +71,7 @@ class FiscalHelper implements FiscalHelperInterface
{ {
// get start mm-dd. Then create a start date in the year passed. // get start mm-dd. Then create a start date in the year passed.
$startDate = clone $date; $startDate = clone $date;
if ($this->useCustomFiscalYear === true) { if (true === $this->useCustomFiscalYear) {
$prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data; $prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
list($mth, $day) = explode('-', $prefStartStr); list($mth, $day) = explode('-', $prefStartStr);
$startDate->month(intval($mth))->day(intval($day)); $startDate->month(intval($mth))->day(intval($day));

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers; namespace FireflyIII\Helpers;
@@ -26,13 +25,10 @@ namespace FireflyIII\Helpers;
use Carbon\Carbon; use Carbon\Carbon;
/** /**
* Interface FiscalHelperInterface * Interface FiscalHelperInterface.
*
* @package FireflyIII\Helpers
*/ */
interface FiscalHelperInterface interface FiscalHelperInterface
{ {
/** /**
* This method produces a clone of the Carbon date object passed, checks preferences * This method produces a clone of the Carbon date object passed, checks preferences
* and calculates the last day of the fiscal year. * and calculates the last day of the fiscal year.

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Help; namespace FireflyIII\Helpers\Help;
@@ -31,9 +30,7 @@ use Requests_Exception;
use Route; use Route;
/** /**
* Class Help * Class Help.
*
* @package FireflyIII\Helpers\Help
*/ */
class Help implements HelpInterface class Help implements HelpInterface
{ {
@@ -76,7 +73,7 @@ class Help implements HelpInterface
Log::debug(sprintf('Status code is %d', $result->status_code)); Log::debug(sprintf('Status code is %d', $result->status_code));
if ($result->status_code === 200) { if (200 === $result->status_code) {
$content = trim($result->body); $content = trim($result->body);
} }
@@ -90,7 +87,6 @@ class Help implements HelpInterface
} }
/** /**
*
* @param string $route * @param string $route
* *
* @return bool * @return bool
@@ -121,11 +117,9 @@ class Help implements HelpInterface
} }
/** /**
*
* @param string $route * @param string $route
* @param string $language * @param string $language
* @param string $content * @param string $content
*
*/ */
public function putInCache(string $route, string $language, string $content) public function putInCache(string $route, string $language, string $content)
{ {

View File

@@ -18,19 +18,15 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Help; namespace FireflyIII\Helpers\Help;
/** /**
* Interface HelpInterface * Interface HelpInterface.
*
* @package FireflyIII\Helpers\Help
*/ */
interface HelpInterface interface HelpInterface
{ {
/** /**
* @param string $route * @param string $route
* @param string $language * @param string $language

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
@@ -34,14 +33,12 @@ use Illuminate\Support\Collection;
use Log; use Log;
/** /**
* Class BalanceReportHelper * Class BalanceReportHelper.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // I can't really help it. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // I can't really help it.
* @package FireflyIII\Helpers\Report
*/ */
class BalanceReportHelper implements BalanceReportHelperInterface class BalanceReportHelper implements BalanceReportHelperInterface
{ {
/** @var BudgetRepositoryInterface */ /** @var BudgetRepositoryInterface */
protected $budgetRepository; protected $budgetRepository;
@@ -56,7 +53,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
$this->budgetRepository = $budgetRepository; $this->budgetRepository = $budgetRepository;
} }
/** /**
* @param Collection $accounts * @param Collection $accounts
* @param Carbon $start * @param Carbon $start
@@ -77,7 +73,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
/** @var BudgetLimit $budgetLimit */ /** @var BudgetLimit $budgetLimit */
foreach ($budgetLimits as $budgetLimit) { foreach ($budgetLimits as $budgetLimit) {
if (!is_null($budgetLimit->budget)) { if (null !== $budgetLimit->budget) {
$line = $this->createBalanceLine($budgetLimit, $accounts); $line = $this->createBalanceLine($budgetLimit, $accounts);
$balance->addBalanceLine($line); $balance->addBalanceLine($line);
} }
@@ -96,7 +92,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
return $balance; return $balance;
} }
/** /**
* @param BudgetLimit $budgetLimit * @param BudgetLimit $budgetLimit
* @param Collection $accounts * @param Collection $accounts
@@ -126,7 +121,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
return $line; return $line;
} }
/** /**
* @param Collection $accounts * @param Collection $accounts
* @param Carbon $start * @param Carbon $start
@@ -150,7 +144,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
return $empty; return $empty;
} }
/** /**
* @param Balance $balance * @param Balance $balance
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
@@ -162,7 +155,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
$set = $balance->getBalanceLines(); $set = $balance->getBalanceLines();
$newSet = new Collection; $newSet = new Collection;
foreach ($set as $entry) { foreach ($set as $entry) {
if (!is_null($entry->getBudget()->id)) { if (null !== $entry->getBudget()->id) {
$sum = '0'; $sum = '0';
foreach ($entry->getBalanceEntries() as $balanceEntry) { foreach ($entry->getBalanceEntries() as $balanceEntry) {
$sum = bcadd($sum, $balanceEntry->getSpent()); $sum = bcadd($sum, $balanceEntry->getSpent());

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
@@ -28,9 +27,7 @@ use FireflyIII\Helpers\Collection\Balance;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface BalanceReportHelperInterface * Interface BalanceReportHelperInterface.
*
* @package FireflyIII\Helpers\Report
*/ */
interface BalanceReportHelperInterface interface BalanceReportHelperInterface
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
@@ -30,9 +29,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class BudgetReportHelper * Class BudgetReportHelper.
*
* @package FireflyIII\Helpers\Report
*/ */
class BudgetReportHelper implements BudgetReportHelperInterface class BudgetReportHelper implements BudgetReportHelperInterface
{ {
@@ -52,6 +49,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
/** /**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // all the arrays make it long. * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // all the arrays make it long.
*
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
@@ -66,9 +64,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
/** @var Budget $budget */ /** @var Budget $budget */
foreach ($set as $budget) { foreach ($set as $budget) {
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end); $budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
if ($budgetLimits->count() === 0) { // no budget limit(s) for this budget if (0 === $budgetLimits->count()) { // no budget limit(s) for this budget
$spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end); // spent for budget in time range
$spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);// spent for budget in time range
if (bccomp($spent, '0') === -1) { if (bccomp($spent, '0') === -1) {
$line = [ $line = [
'type' => 'budget', 'type' => 'budget',
@@ -156,9 +153,9 @@ class BudgetReportHelper implements BudgetReportHelperInterface
{ {
$array = []; $array = [];
$expenses = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date); $expenses = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date);
$array['left'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? bcadd($budgetLimit->amount, $expenses) : '0'; $array['left'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? bcadd($budgetLimit->amount, $expenses) : '0';
$array['spent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? $expenses : '0'; $array['spent'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? $expenses : '0';
$array['overspent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? '0' : bcadd($expenses, $budgetLimit->amount); $array['overspent'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? '0' : bcadd($expenses, $budgetLimit->amount);
$array['expenses'] = $expenses; $array['expenses'] = $expenses;
return $array; return $array;

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
@@ -27,13 +26,10 @@ use Carbon\Carbon;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface BudgetReportHelperInterface * Interface BudgetReportHelperInterface.
*
* @package FireflyIII\Helpers\Report
*/ */
interface BudgetReportHelperInterface interface BudgetReportHelperInterface
{ {
/** /**
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
@@ -32,14 +31,10 @@ use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class PopupReport * Class PopupReport.
*
* @package FireflyIII\Helpers\Report
*/ */
class PopupReport implements PopupReportInterface class PopupReport implements PopupReportInterface
{ {
/** /**
* @param $account * @param $account
* @param $attributes * @param $attributes
@@ -58,11 +53,10 @@ class PopupReport implements PopupReportInterface
->withoutBudget(); ->withoutBudget();
$journals = $collector->getJournals(); $journals = $collector->getJournals();
return $journals->filter( return $journals->filter(
function (Transaction $transaction) { function (Transaction $transaction) {
$tags = $transaction->transactionJournal->tags()->where('tagMode', 'balancingAct')->count(); $tags = $transaction->transactionJournal->tags()->where('tagMode', 'balancingAct')->count();
if ($tags === 0) { if (0 === $tags) {
return true; return true;
} }
@@ -120,10 +114,10 @@ class PopupReport implements PopupReportInterface
$collector->setAccounts($attributes['accounts'])->setRange($attributes['startDate'], $attributes['endDate']); $collector->setAccounts($attributes['accounts'])->setRange($attributes['startDate'], $attributes['endDate']);
if (is_null($budget->id)) { if (null === $budget->id) {
$collector->setTypes([TransactionType::WITHDRAWAL])->withoutBudget(); $collector->setTypes([TransactionType::WITHDRAWAL])->withoutBudget();
} }
if (!is_null($budget->id)) { if (null !== $budget->id) {
$collector->setBudget($budget); $collector->setBudget($budget);
} }
$journals = $collector->getJournals(); $journals = $collector->getJournals();

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
@@ -29,13 +28,10 @@ use FireflyIII\Models\Category;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface PopupReportInterface * Interface PopupReportInterface.
*
* @package FireflyIII\Helpers\Report
*/ */
interface PopupReportInterface interface PopupReportInterface
{ {
/** /**
* @param $account * @param $account
* @param $attributes * @param $attributes

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
@@ -35,13 +34,10 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class ReportHelper * Class ReportHelper.
*
* @package FireflyIII\Helpers\Report
*/ */
class ReportHelper implements ReportHelperInterface class ReportHelper implements ReportHelperInterface
{ {
/** @var BudgetRepositoryInterface */ /** @var BudgetRepositoryInterface */
protected $budgetRepository; protected $budgetRepository;
@@ -95,7 +91,7 @@ class ReportHelper implements ReportHelperInterface
} }
); );
$first = $entry->first(); $first = $entry->first();
if (!is_null($first)) { if (null !== $first) {
$billLine->setTransactionJournalId($first->id); $billLine->setTransactionJournalId($first->id);
$billLine->setAmount($first->transaction_amount); $billLine->setAmount($first->transaction_amount);
$billLine->setLastHitDate($first->date); $billLine->setLastHitDate($first->date);

View File

@@ -18,25 +18,19 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Collection\Bill as BillCollection; use FireflyIII\Helpers\Collection\Bill as BillCollection;
use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Interface ReportHelperInterface * Interface ReportHelperInterface.
*
* @package FireflyIII\Helpers\Report
*/ */
interface ReportHelperInterface interface ReportHelperInterface
{ {
/** /**
* This method generates a full report for the given period on all * This method generates a full report for the given period on all
* the users bills and their payments. * the users bills and their payments.

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Account; namespace FireflyIII\Http\Controllers\Account;
@@ -37,9 +36,7 @@ use Response;
use View; use View;
/** /**
* Class ReconcileController * Class ReconcileController.
*
* @package FireflyIII\Http\Controllers\Account
*/ */
class ReconcileController extends Controller class ReconcileController extends Controller
{ {
@@ -94,14 +91,14 @@ class ReconcileController extends Controller
*/ */
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
{ {
if ($account->accountType->type === AccountType::INITIAL_BALANCE) { if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account); return $this->redirectToOriginalAccount($account);
} }
/** @var CurrencyRepositoryInterface $currencyRepos */ /** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class); $currencyRepos = app(CurrencyRepositoryInterface::class);
$currencyId = intval($account->getMeta('currency_id')); $currencyId = intval($account->getMeta('currency_id'));
$currency = $currencyRepos->find($currencyId); $currency = $currencyRepos->find($currencyId);
if ($currencyId === 0) { if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
} }
@@ -109,11 +106,11 @@ class ReconcileController extends Controller
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
// get start and end // get start and end
if (is_null($start) && is_null($end)) { if (null === $start && null === $end) {
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range)); $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range)); $end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
} }
if (is_null($end)) { if (null === $end) {
$end = Navigation::endOfPeriod($start, $range); $end = Navigation::endOfPeriod($start, $range);
} }
@@ -158,7 +155,7 @@ class ReconcileController extends Controller
*/ */
public function transactions(Account $account, Carbon $start, Carbon $end) public function transactions(Account $account, Carbon $start, Carbon $end)
{ {
if ($account->accountType->type === AccountType::INITIAL_BALANCE) { if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account); return $this->redirectToOriginalAccount($account);
} }
@@ -168,7 +165,6 @@ class ReconcileController extends Controller
$selectionEnd = clone $end; $selectionEnd = clone $end;
$selectionEnd->addDays(3); $selectionEnd->addDays(3);
// grab transactions: // grab transactions:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
@@ -45,9 +44,8 @@ use Steam;
use View; use View;
/** /**
* Class AccountController * Class AccountController.
* *
* @package FireflyIII\Http\Controllers
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/ */
class AccountController extends Controller class AccountController extends Controller
@@ -90,12 +88,11 @@ class AccountController extends Controller
$roles[$role] = strval(trans('firefly.account_role_' . $role)); $roles[$role] = strval(trans('firefly.account_role_' . $role));
} }
// pre fill some data // pre fill some data
$request->session()->flash('preFilled', ['currency_id' => $defaultCurrency->id,]); $request->session()->flash('preFilled', ['currency_id' => $defaultCurrency->id]);
// put previous url in session if not redirect from store (not "create another"). // put previous url in session if not redirect from store (not "create another").
if (session('accounts.create.fromStore') !== true) { if (true !== session('accounts.create.fromStore')) {
$this->rememberPreviousUri('accounts.create.uri'); $this->rememberPreviousUri('accounts.create.uri');
} }
$request->session()->forget('accounts.create.fromStore'); $request->session()->forget('accounts.create.fromStore');
@@ -174,9 +171,8 @@ class AccountController extends Controller
$roles[$role] = strval(trans('firefly.account_role_' . $role)); $roles[$role] = strval(trans('firefly.account_role_' . $role));
} }
// put previous url in session if not redirect from store (not "return_to_edit"). // put previous url in session if not redirect from store (not "return_to_edit").
if (session('accounts.edit.fromUpdate') !== true) { if (true !== session('accounts.edit.fromUpdate')) {
$this->rememberPreviousUri('accounts.edit.uri'); $this->rememberPreviousUri('accounts.edit.uri');
} }
$request->session()->forget('accounts.edit.fromUpdate'); $request->session()->forget('accounts.edit.fromUpdate');
@@ -185,9 +181,9 @@ class AccountController extends Controller
// the opening balance is tricky: // the opening balance is tricky:
$openingBalanceAmount = $account->getOpeningBalanceAmount(); $openingBalanceAmount = $account->getOpeningBalanceAmount();
$openingBalanceAmount = $account->getOpeningBalanceAmount() === '0' ? '' : $openingBalanceAmount; $openingBalanceAmount = '0' === $account->getOpeningBalanceAmount() ? '' : $openingBalanceAmount;
$openingBalanceDate = $account->getOpeningBalanceDate(); $openingBalanceDate = $account->getOpeningBalanceDate();
$openingBalanceDate = $openingBalanceDate->year === 1900 ? null : $openingBalanceDate->format('Y-m-d'); $openingBalanceDate = 1900 === $openingBalanceDate->year ? null : $openingBalanceDate->format('Y-m-d');
$currency = $repository->find(intval($account->getMeta('currency_id'))); $currency = $repository->find(intval($account->getMeta('currency_id')));
$preFilled = [ $preFilled = [
@@ -200,7 +196,6 @@ class AccountController extends Controller
'openingBalance' => $openingBalanceAmount, 'openingBalance' => $openingBalanceAmount,
'virtualBalance' => $account->virtual_balance, 'virtualBalance' => $account->virtual_balance,
'currency_id' => $currency->id, 'currency_id' => $currency->id,
]; ];
$request->session()->flash('preFilled', $preFilled); $request->session()->flash('preFilled', $preFilled);
$request->session()->flash('gaEventCategory', 'accounts'); $request->session()->flash('gaEventCategory', 'accounts');
@@ -273,7 +268,7 @@ class AccountController extends Controller
*/ */
public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = '') public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = '')
{ {
if ($account->accountType->type === AccountType::INITIAL_BALANCE) { if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account); return $this->redirectToOriginalAccount($account);
} }
/** @var CurrencyRepositoryInterface $currencyRepos */ /** @var CurrencyRepositoryInterface $currencyRepos */
@@ -288,13 +283,12 @@ class AccountController extends Controller
$periods = new Collection; $periods = new Collection;
$currencyId = intval($account->getMeta('currency_id')); $currencyId = intval($account->getMeta('currency_id'));
$currency = $currencyRepos->find($currencyId); $currency = $currencyRepos->find($currencyId);
if ($currencyId === 0) { if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
} }
// prep for "all" view. // prep for "all" view.
if ($moment === 'all') { if ('all' === $moment) {
$subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]); $subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]);
$chartUri = route('chart.account.all', [$account->id]); $chartUri = route('chart.account.all', [$account->id]);
$first = $repository->first(); $first = $repository->first();
@@ -303,7 +297,7 @@ class AccountController extends Controller
} }
// prep for "specific date" view. // prep for "specific date" view.
if (strlen($moment) > 0 && $moment !== 'all') { if (strlen($moment) > 0 && 'all' !== $moment) {
$start = new Carbon($moment); $start = new Carbon($moment);
$end = Navigation::endOfPeriod($start, $range); $end = Navigation::endOfPeriod($start, $range);
$fStart = $start->formatLocalized($this->monthAndDayFormat); $fStart = $start->formatLocalized($this->monthAndDayFormat);
@@ -314,7 +308,7 @@ class AccountController extends Controller
} }
// prep for current period view // prep for current period view
if (strlen($moment) === 0) { if (0 === strlen($moment)) {
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range)); $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range)); $end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
$fStart = $start->formatLocalized($this->monthAndDayFormat); $fStart = $start->formatLocalized($this->monthAndDayFormat);
@@ -326,7 +320,7 @@ class AccountController extends Controller
// grab journals: // grab journals:
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
if (!is_null($start)) { if (null !== $start) {
$collector->setRange($start, $end); $collector->setRange($start, $end);
} }
$transactions = $collector->getPaginatedJournals(); $transactions = $collector->getPaginatedJournals();
@@ -343,7 +337,6 @@ class AccountController extends Controller
* @param AccountRepositoryInterface $repository * @param AccountRepositoryInterface $repository
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
*/ */
public function store(AccountFormRequest $request, AccountRepositoryInterface $repository) public function store(AccountFormRequest $request, AccountRepositoryInterface $repository)
{ {
@@ -354,12 +347,12 @@ class AccountController extends Controller
// update preferences if necessary: // update preferences if necessary:
$frontPage = Preferences::get('frontPageAccounts', [])->data; $frontPage = Preferences::get('frontPageAccounts', [])->data;
if (count($frontPage) > 0 && $account->accountType->type === AccountType::ASSET) { if (count($frontPage) > 0 && AccountType::ASSET === $account->accountType->type) {
$frontPage[] = $account->id; $frontPage[] = $account->id;
Preferences::set('frontPageAccounts', $frontPage); Preferences::set('frontPageAccounts', $frontPage);
} }
if (intval($request->get('create_another')) === 1) { if (1 === intval($request->get('create_another'))) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
$request->session()->put('accounts.create.fromStore', true); $request->session()->put('accounts.create.fromStore', true);
@@ -385,7 +378,7 @@ class AccountController extends Controller
$request->session()->flash('success', strval(trans('firefly.updated_account', ['name' => $account->name]))); $request->session()->flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
Preferences::mark(); Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) { if (1 === intval($request->get('return_to_edit'))) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:
$request->session()->put('accounts.edit.fromUpdate', true); $request->session()->put('accounts.edit.fromUpdate', true);
@@ -396,7 +389,6 @@ class AccountController extends Controller
return redirect($this->getPreviousUri('accounts.edit.uri')); return redirect($this->getPreviousUri('accounts.edit.uri'));
} }
/** /**
* @param array $array * @param array $array
* @param int $entryId * @param int $entryId
@@ -468,10 +460,10 @@ class AccountController extends Controller
'name' => $dateName, 'name' => $dateName,
'spent' => $spent, 'spent' => $spent,
'earned' => $earned, 'earned' => $earned,
'date' => clone $end] 'date' => clone $end,]
); );
$end = Navigation::subtractPeriod($end, $range, 1); $end = Navigation::subtractPeriod($end, $range, 1);
$count++; ++$count;
} }
$cache->store($entries); $cache->store($entries);
@@ -482,13 +474,14 @@ class AccountController extends Controller
* @param Account $account * @param Account $account
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException * @throws FireflyException
*/ */
private function redirectToOriginalAccount(Account $account) private function redirectToOriginalAccount(Account $account)
{ {
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $account->transactions()->first(); $transaction = $account->transactions()->first();
if (is_null($transaction)) { if (null === $transaction) {
throw new FireflyException('Expected a transaction. This account has none. BEEP, error.'); throw new FireflyException('Expected a transaction. This account has none. BEEP, error.');
} }
@@ -496,7 +489,7 @@ class AccountController extends Controller
/** @var Transaction $opposingTransaction */ /** @var Transaction $opposingTransaction */
$opposingTransaction = $journal->transactions()->where('transactions.id', '!=', $transaction->id)->first(); $opposingTransaction = $journal->transactions()->where('transactions.id', '!=', $transaction->id)->first();
if (is_null($opposingTransaction)) { if (null === $opposingTransaction) {
throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.'); // @codeCoverageIgnore throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.'); // @codeCoverageIgnore
} }

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
@@ -32,9 +31,7 @@ use Session;
use View; use View;
/** /**
* Class ConfigurationController * Class ConfigurationController.
*
* @package FireflyIII\Http\Controllers\Admin
*/ */
class ConfigurationController extends Controller class ConfigurationController extends Controller
{ {
@@ -45,7 +42,6 @@ class ConfigurationController extends Controller
{ {
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
View::share('title', strval(trans('firefly.administration'))); View::share('title', strval(trans('firefly.administration')));

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
@@ -30,9 +29,7 @@ use Log;
use Session; use Session;
/** /**
* Class HomeController * Class HomeController.
*
* @package FireflyIII\Http\Controllers\Admin
*/ */
class HomeController extends Controller class HomeController extends Controller
{ {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
@@ -32,9 +31,7 @@ use Preferences;
use View; use View;
/** /**
* Class LinkController * Class LinkController.
*
* @package FireflyIII\Http\Controllers\Admin
*/ */
class LinkController extends Controller class LinkController extends Controller
{ {
@@ -64,7 +61,7 @@ class LinkController extends Controller
$subTitleIcon = 'fa-link'; $subTitleIcon = 'fa-link';
// put previous url in session if not redirect from store (not "create another"). // put previous url in session if not redirect from store (not "create another").
if (session('link_types.create.fromStore') !== true) { if (true !== session('link_types.create.fromStore')) {
$this->rememberPreviousUri('link_types.create.uri'); $this->rememberPreviousUri('link_types.create.uri');
} }
@@ -139,7 +136,7 @@ class LinkController extends Controller
$subTitleIcon = 'fa-link'; $subTitleIcon = 'fa-link';
// put previous url in session if not redirect from store (not "return_to_edit"). // put previous url in session if not redirect from store (not "return_to_edit").
if (session('link_types.edit.fromUpdate') !== true) { if (true !== session('link_types.edit.fromUpdate')) {
$this->rememberPreviousUri('link_types.edit.uri'); $this->rememberPreviousUri('link_types.edit.uri');
} }
$request->session()->forget('link_types.edit.fromUpdate'); $request->session()->forget('link_types.edit.fromUpdate');
@@ -196,7 +193,7 @@ class LinkController extends Controller
$linkType = $repository->store($data); $linkType = $repository->store($data);
$request->session()->flash('success', strval(trans('firefly.stored_new_link_type', ['name' => $linkType->name]))); $request->session()->flash('success', strval(trans('firefly.stored_new_link_type', ['name' => $linkType->name])));
if (intval($request->get('create_another')) === 1) { if (1 === intval($request->get('create_another'))) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
$request->session()->put('link_types.create.fromStore', true); $request->session()->put('link_types.create.fromStore', true);
@@ -225,7 +222,7 @@ class LinkController extends Controller
$request->session()->flash('success', strval(trans('firefly.updated_link_type', ['name' => $linkType->name]))); $request->session()->flash('success', strval(trans('firefly.updated_link_type', ['name' => $linkType->name])));
Preferences::mark(); Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) { if (1 === intval($request->get('return_to_edit'))) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:
$request->session()->put('link_types.edit.fromUpdate', true); $request->session()->put('link_types.edit.fromUpdate', true);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
@@ -33,9 +32,7 @@ use Session;
use View; use View;
/** /**
* Class UserController * Class UserController.
*
* @package FireflyIII\Http\Controllers\Admin
*/ */
class UserController extends Controller class UserController extends Controller
{ {
@@ -46,7 +43,6 @@ class UserController extends Controller
{ {
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
View::share('title', strval(trans('firefly.administration'))); View::share('title', strval(trans('firefly.administration')));
@@ -91,7 +87,7 @@ class UserController extends Controller
public function edit(User $user) public function edit(User $user)
{ {
// put previous url in session if not redirect from store (not "return_to_edit"). // put previous url in session if not redirect from store (not "return_to_edit").
if (session('users.edit.fromUpdate') !== true) { if (true !== session('users.edit.fromUpdate')) {
$this->rememberPreviousUri('users.edit.uri'); $this->rememberPreviousUri('users.edit.uri');
} }
Session::forget('users.edit.fromUpdate'); Session::forget('users.edit.fromUpdate');
@@ -125,14 +121,13 @@ class UserController extends Controller
$list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret']; $list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret'];
$preferences = Preferences::getArrayForUser($user, $list); $preferences = Preferences::getArrayForUser($user, $list);
$user->isAdmin = $user->hasRole('owner'); $user->isAdmin = $user->hasRole('owner');
$is2faEnabled = $preferences['twoFactorAuthEnabled'] === true; $is2faEnabled = true === $preferences['twoFactorAuthEnabled'];
$has2faSecret = !is_null($preferences['twoFactorAuthSecret']); $has2faSecret = null !== $preferences['twoFactorAuthSecret'];
$user->has2FA = ($is2faEnabled && $has2faSecret) ? true : false; $user->has2FA = ($is2faEnabled && $has2faSecret) ? true : false;
$user->prefs = $preferences; $user->prefs = $preferences;
} }
); );
return view('admin.users.index', compact('subTitle', 'subTitleIcon', 'users')); return view('admin.users.index', compact('subTitle', 'subTitleIcon', 'users'));
} }
@@ -166,7 +161,6 @@ class UserController extends Controller
/** /**
* @param UserFormRequest $request * @param UserFormRequest $request
* @param User $user * @param User $user
*
* @param UserRepositoryInterface $repository * @param UserRepositoryInterface $repository
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
@@ -187,7 +181,7 @@ class UserController extends Controller
Session::flash('success', strval(trans('firefly.updated_user', ['email' => $user->email]))); Session::flash('success', strval(trans('firefly.updated_user', ['email' => $user->email])));
Preferences::mark(); Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) { if (1 === intval($request->get('return_to_edit'))) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
Session::put('users.edit.fromUpdate', true); Session::put('users.edit.fromUpdate', true);

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
@@ -35,15 +34,12 @@ use Response;
use View; use View;
/** /**
* Class AttachmentController * Class AttachmentController.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it's 13. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it's 13.
*
* @package FireflyIII\Http\Controllers
*/ */
class AttachmentController extends Controller class AttachmentController extends Controller
{ {
/** /**
* *
*/ */
@@ -104,6 +100,7 @@ class AttachmentController extends Controller
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return mixed * @return mixed
*
* @throws FireflyException * @throws FireflyException
*/ */
public function download(AttachmentRepositoryInterface $repository, Attachment $attachment) public function download(AttachmentRepositoryInterface $repository, Attachment $attachment)
@@ -112,7 +109,6 @@ class AttachmentController extends Controller
$content = $repository->getContent($attachment); $content = $repository->getContent($attachment);
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\')); $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
/** @var LaravelResponse $response */ /** @var LaravelResponse $response */
$response = response($content, 200); $response = response($content, 200);
$response $response
@@ -143,7 +139,7 @@ class AttachmentController extends Controller
$subTitle = trans('firefly.edit_attachment', ['name' => $attachment->filename]); $subTitle = trans('firefly.edit_attachment', ['name' => $attachment->filename]);
// put previous url in session if not redirect from store (not "return_to_edit"). // put previous url in session if not redirect from store (not "return_to_edit").
if (session('attachments.edit.fromUpdate') !== true) { if (true !== session('attachments.edit.fromUpdate')) {
$this->rememberPreviousUri('attachments.edit.uri'); $this->rememberPreviousUri('attachments.edit.uri');
} }
$request->session()->forget('attachments.edit.fromUpdate'); $request->session()->forget('attachments.edit.fromUpdate');
@@ -160,8 +156,7 @@ class AttachmentController extends Controller
{ {
$image = 'images/page_green.png'; $image = 'images/page_green.png';
if ('application/pdf' === $attachment->mime) {
if ($attachment->mime === 'application/pdf') {
$image = 'images/page_white_acrobat.png'; $image = 'images/page_white_acrobat.png';
} }
$file = public_path($image); $file = public_path($image);
@@ -171,7 +166,6 @@ class AttachmentController extends Controller
return $response; return $response;
} }
/** /**
* @param AttachmentFormRequest $request * @param AttachmentFormRequest $request
* @param AttachmentRepositoryInterface $repository * @param AttachmentRepositoryInterface $repository
@@ -187,7 +181,7 @@ class AttachmentController extends Controller
$request->session()->flash('success', strval(trans('firefly.attachment_updated', ['name' => $attachment->filename]))); $request->session()->flash('success', strval(trans('firefly.attachment_updated', ['name' => $attachment->filename])));
Preferences::mark(); Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) { if (1 === intval($request->get('return_to_edit'))) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$request->session()->put('attachments.edit.fromUpdate', true); $request->session()->put('attachments.edit.fromUpdate', true);

View File

@@ -18,10 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
/** /**
* ForgotPasswordController.php * ForgotPasswordController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -53,7 +51,6 @@ class ForgotPasswordController extends Controller
/** /**
* Create a new controller instance. * Create a new controller instance.
*
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -18,10 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
/** /**
* LoginController.php * LoginController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -66,7 +64,6 @@ class LoginController extends Controller
/** /**
* Create a new controller instance. * Create a new controller instance.
*
*/ */
public function __construct() public function __construct()
{ {
@@ -93,7 +90,7 @@ class LoginController extends Controller
// check for presence of currency: // check for presence of currency:
$currency = TransactionCurrency::where('code', 'EUR')->first(); $currency = TransactionCurrency::where('code', 'EUR')->first();
if (is_null($currency)) { if (null === $currency) {
$message $message
= 'Firefly III could not find the EURO currency. This is a strong indication the database has not been initialized correctly. Did you follow the installation instructions?'; = 'Firefly III could not find the EURO currency. This is a strong indication the database has not been initialized correctly. Did you follow the installation instructions?';
@@ -107,7 +104,7 @@ class LoginController extends Controller
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count(); $userCount = User::count();
$allowRegistration = true; $allowRegistration = true;
if ($singleUserMode === true && $userCount > 0) { if (true === $singleUserMode && $userCount > 0) {
$allowRegistration = false; $allowRegistration = false;
} }

View File

@@ -18,10 +18,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
/** /**
* RegisterController.php * RegisterController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -66,7 +64,6 @@ class RegisterController extends Controller
/** /**
* Create a new controller instance. * Create a new controller instance.
*
*/ */
public function __construct() public function __construct()
{ {
@@ -86,7 +83,7 @@ class RegisterController extends Controller
// is allowed to? // is allowed to?
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count(); $userCount = User::count();
if ($singleUserMode === true && $userCount > 0) { if (true === $singleUserMode && $userCount > 0) {
$message = 'Registration is currently not available.'; $message = 'Registration is currently not available.';
return view('error', compact('message')); return view('error', compact('message'));
@@ -119,7 +116,7 @@ class RegisterController extends Controller
// is allowed to? // is allowed to?
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count(); $userCount = User::count();
if ($singleUserMode === true && $userCount > 0) { if (true === $singleUserMode && $userCount > 0) {
$message = 'Registration is currently not available.'; $message = 'Registration is currently not available.';
return view('error', compact('message')); return view('error', compact('message'));
@@ -127,7 +124,6 @@ class RegisterController extends Controller
$email = $request->old('email'); $email = $request->old('email');
return view('auth.register', compact('isDemoSite', 'email')); return view('auth.register', compact('isDemoSite', 'email'));
} }

Some files were not shown because too many files have changed in this diff Show More