Skip to content

Firefly III: a personal finances manager

Code cleanup and documentation improvements.

James Colea76241c7ba5e
diff --git a/app/Api/V1/Controllers/AboutController.php b/app/Api/V1/Controllers/AboutController.php
index 2f7795d05c..7c5e034bb3 100644
--- a/app/Api/V1/Controllers/AboutController.php
+++ b/app/Api/V1/Controllers/AboutController.php
@@ -35,7 +35,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
/**
* Returns basic information about this installation.
*
- * Class AboutController
+ * Class AboutController.
*/
class AboutController extends Controller
{
diff --git a/app/Api/V1/Controllers/AccountController.php b/app/Api/V1/Controllers/AccountController.php
index b7472c452b..9fef764538 100644
--- a/app/Api/V1/Controllers/AccountController.php
+++ b/app/Api/V1/Controllers/AccountController.php
@@ -1,5 +1,4 @@
<?php
-
/**
* AccountController.php
* Copyright (c) 2018 [email protected]
@@ -41,14 +40,15 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class AccountController
+ * Class AccountController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AccountController extends Controller
{
- /** @var CurrencyRepositoryInterface */
+ /** @var CurrencyRepositoryInterface The currency repository */
private $currencyRepository;
- /** @var AccountRepositoryInterface */
+ /** @var AccountRepositoryInterface The account repository */
private $repository;
/**
@@ -126,6 +126,8 @@ class AccountController extends Controller
}
/**
+ * Show single instance.
+ *
* @param Request $request
* @param Account $account
*
@@ -147,6 +149,8 @@ class AccountController extends Controller
}
/**
+ * Store a new instance.
+ *
* @param AccountRequest $request
*
* @return \Illuminate\Http\JsonResponse
@@ -198,13 +202,15 @@ class AccountController extends Controller
}
/**
+ * All the available types.
+ *
* @param string $type
*
* @return array
*/
private function mapTypes(string $type): array
{
- $types = [
+ $types = [
'all' => [AccountType::DEFAULT, AccountType::CASH, AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE,
AccountType::INITIAL_BALANCE, AccountType::BENEFICIARY, AccountType::IMPORT, AccountType::RECONCILIATION,
AccountType::LOAN,],
@@ -226,10 +232,11 @@ class AccountController extends Controller
AccountType::RECONCILIATION => [AccountType::RECONCILIATION],
AccountType::LOAN => [AccountType::LOAN],
];
+ $return = $types['all'];
if (isset($types[$type])) {
- return $types[$type];
+ $return = $types[$type];
}
- return $types['all']; // @codeCoverageIgnore
+ return $return; // @codeCoverageIgnore
}
}
diff --git a/app/Api/V1/Controllers/AttachmentController.php b/app/Api/V1/Controllers/AttachmentController.php
index 0629d01c1b..c416e57a7f 100644
--- a/app/Api/V1/Controllers/AttachmentController.php
+++ b/app/Api/V1/Controllers/AttachmentController.php
@@ -41,12 +41,13 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class AttachmentController
+ * Class AttachmentController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AttachmentController extends Controller
{
- /** @var AttachmentRepositoryInterface */
+ /** @var AttachmentRepositoryInterface The attachment repository */
private $repository;
/**
@@ -82,6 +83,8 @@ class AttachmentController extends Controller
}
/**
+ * Download an attachment.
+ *
* @param Attachment $attachment
*
* @return LaravelResponse
@@ -212,6 +215,8 @@ class AttachmentController extends Controller
}
/**
+ * Upload an attachment.
+ *
* @param Request $request
* @param Attachment $attachment
*
diff --git a/app/Api/V1/Controllers/AvailableBudgetController.php b/app/Api/V1/Controllers/AvailableBudgetController.php
index ace43d0daf..92fbfae79f 100644
--- a/app/Api/V1/Controllers/AvailableBudgetController.php
+++ b/app/Api/V1/Controllers/AvailableBudgetController.php
@@ -40,14 +40,15 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class AvailableBudgetController
+ * Class AvailableBudgetController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AvailableBudgetController extends Controller
{
- /** @var CurrencyRepositoryInterface */
+ /** @var CurrencyRepositoryInterface The currency repository */
private $currencyRepository;
- /** @var BudgetRepositoryInterface */
+ /** @var BudgetRepositoryInterface The budget repository */
private $repository;
/**
diff --git a/app/Api/V1/Controllers/BillController.php b/app/Api/V1/Controllers/BillController.php
index 191bb9c4ee..4f438df8b9 100644
--- a/app/Api/V1/Controllers/BillController.php
+++ b/app/Api/V1/Controllers/BillController.php
@@ -40,11 +40,11 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class BillController
+ * Class BillController.
*/
class BillController extends Controller
{
- /** @var BillRepositoryInterface */
+ /** @var BillRepositoryInterface The bill repository */
private $repository;
/**
@@ -107,6 +107,8 @@ class BillController extends Controller
/**
+ * Show the specified bill.
+ *
* @param Request $request
* @param Bill $bill
*
@@ -128,6 +130,8 @@ class BillController extends Controller
}
/**
+ * Store a bill.
+ *
* @param BillRequest $request
*
* @return JsonResponse
@@ -151,6 +155,8 @@ class BillController extends Controller
/**
+ * Update a bill.
+ *
* @param BillRequest $request
* @param Bill $bill
*
diff --git a/app/Api/V1/Controllers/BudgetController.php b/app/Api/V1/Controllers/BudgetController.php
index 4fbb38a04e..38ad437017 100644
--- a/app/Api/V1/Controllers/BudgetController.php
+++ b/app/Api/V1/Controllers/BudgetController.php
@@ -39,12 +39,13 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class BudgetController
+ * Class BudgetController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class BudgetController extends Controller
{
- /** @var BudgetRepositoryInterface */
+ /** @var BudgetRepositoryInterface The budget repository */
private $repository;
/**
@@ -116,6 +117,8 @@ class BudgetController extends Controller
/**
+ * Show a budget.
+ *
* @param Request $request
* @param Budget $budget
*
@@ -137,6 +140,8 @@ class BudgetController extends Controller
}
/**
+ * Store a budget.
+ *
* @param BudgetRequest $request
*
* @return JsonResponse
@@ -159,6 +164,8 @@ class BudgetController extends Controller
/**
+ * Update a budget.
+ *
* @param BudgetRequest $request
* @param Budget $budget
*
diff --git a/app/Api/V1/Controllers/BudgetLimitController.php b/app/Api/V1/Controllers/BudgetLimitController.php
index 85e1ae3f84..80dc9f464e 100644
--- a/app/Api/V1/Controllers/BudgetLimitController.php
+++ b/app/Api/V1/Controllers/BudgetLimitController.php
@@ -43,12 +43,13 @@ use League\Fractal\Serializer\JsonApiSerializer;
use Log;
/**
- * Class BudgetLimitController
+ * Class BudgetLimitController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class BudgetLimitController extends Controller
{
- /** @var BudgetRepositoryInterface */
+ /** @var BudgetRepositoryInterface The budget repository */
private $repository;
/**
diff --git a/app/Api/V1/Controllers/CategoryController.php b/app/Api/V1/Controllers/CategoryController.php
index b41cc34434..cbc69366ba 100644
--- a/app/Api/V1/Controllers/CategoryController.php
+++ b/app/Api/V1/Controllers/CategoryController.php
@@ -39,12 +39,13 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class CategoryController
+ * Class CategoryController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CategoryController extends Controller
{
- /** @var CategoryRepositoryInterface */
+ /** @var CategoryRepositoryInterface The category repository */
private $repository;
/**
@@ -116,6 +117,8 @@ class CategoryController extends Controller
/**
+ * Show the category.
+ *
* @param Request $request
* @param Category $category
*
@@ -137,6 +140,8 @@ class CategoryController extends Controller
}
/**
+ * Store new category.
+ *
* @param CategoryRequest $request
*
* @return JsonResponse
@@ -159,6 +164,8 @@ class CategoryController extends Controller
/**
+ * Update the category.
+ *
* @param CategoryRequest $request
* @param Category $category
*
diff --git a/app/Api/V1/Controllers/ConfigurationController.php b/app/Api/V1/Controllers/ConfigurationController.php
index 84491b6615..46cadefeaa 100644
--- a/app/Api/V1/Controllers/ConfigurationController.php
+++ b/app/Api/V1/Controllers/ConfigurationController.php
@@ -31,13 +31,13 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/**
- * Class ConfigurationController
+ * Class ConfigurationController.
*/
class ConfigurationController extends Controller
{
- /** @var UserRepositoryInterface */
+ /** @var UserRepositoryInterface The user repository */
private $repository;
/**
@@ -63,6 +63,8 @@ class ConfigurationController extends Controller
}
/**
+ * Show all configuration.
+ *
* @return JsonResponse
*/
public function index(): JsonResponse
@@ -73,6 +75,8 @@ class ConfigurationController extends Controller
}
/**
+ * Update the configuration.
+ *
* @param Request $request
*
* @return JsonResponse
@@ -104,6 +108,8 @@ class ConfigurationController extends Controller
}
/**
+ * Get all config values.
+ *
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php
index a95d8e7940..9a73e7a28a 100644
--- a/app/Api/V1/Controllers/Controller.php
+++ b/app/Api/V1/Controllers/Controller.php
@@ -43,7 +43,7 @@ class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
- /** @var ParameterBag */
+ /** @var ParameterBag Parameters from the URI are stored here. */
protected $parameters;
/**
@@ -57,6 +57,8 @@ class Controller extends BaseController
}
/**
+ * Method to help build URI's.
+ *
* @return string
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -81,6 +83,8 @@ class Controller extends BaseController
}
/**
+ * Method to grab all parameters from the URI.
+ *
* @return ParameterBag
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
diff --git a/app/Api/V1/Controllers/CurrencyController.php b/app/Api/V1/Controllers/CurrencyController.php
index e42a1c2a45..6bda7e05a7 100644
--- a/app/Api/V1/Controllers/CurrencyController.php
+++ b/app/Api/V1/Controllers/CurrencyController.php
@@ -41,14 +41,15 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class CurrencyController
+ * Class CurrencyController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CurrencyController extends Controller
{
- /** @var CurrencyRepositoryInterface */
+ /** @var CurrencyRepositoryInterface The currency repository */
private $repository;
- /** @var UserRepositoryInterface */
+ /** @var UserRepositoryInterface The user repository */
private $userRepository;
/**
@@ -129,6 +130,8 @@ class CurrencyController extends Controller
/**
+ * Show a currency.
+ *
* @param Request $request
* @param TransactionCurrency $currency
*
@@ -152,6 +155,8 @@ class CurrencyController extends Controller
}
/**
+ * Store new currency.
+ *
* @param CurrencyRequest $request
*
* @return JsonResponse
@@ -182,6 +187,8 @@ class CurrencyController extends Controller
/**
+ * Update a currency.
+ *
* @param CurrencyRequest $request
* @param TransactionCurrency $currency
*
diff --git a/app/Api/V1/Controllers/CurrencyExchangeRateController.php b/app/Api/V1/Controllers/CurrencyExchangeRateController.php
index cc5a31fdce..f66c3ac89f 100644
--- a/app/Api/V1/Controllers/CurrencyExchangeRateController.php
+++ b/app/Api/V1/Controllers/CurrencyExchangeRateController.php
@@ -36,12 +36,11 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- *
* Class CurrencyExchangeRateController
*/
class CurrencyExchangeRateController extends Controller
{
- /** @var CurrencyRepositoryInterface */
+ /** @var CurrencyRepositoryInterface The currency repository */
private $repository;
/**
@@ -65,6 +64,8 @@ class CurrencyExchangeRateController extends Controller
}
/**
+ * Show an exchange rate.
+ *
* @param Request $request
*
* @return JsonResponse
diff --git a/app/Api/V1/Controllers/JournalLinkController.php b/app/Api/V1/Controllers/JournalLinkController.php
index 3c658c5cc3..ce6ae8a200 100644
--- a/app/Api/V1/Controllers/JournalLinkController.php
+++ b/app/Api/V1/Controllers/JournalLinkController.php
@@ -40,17 +40,20 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
+ * Class JournalLinkController.
*
- * Class JournalLinkController
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class JournalLinkController extends Controller
{
- /** @var JournalRepositoryInterface */
+ /** @var JournalRepositoryInterface The journal repository */
private $journalRepository;
- /** @var LinkTypeRepositoryInterface */
+ /** @var LinkTypeRepositoryInterface The link type repository */
private $repository;
+ /**
+ * JournalLinkController constructor.
+ */
public function __construct()
{
parent::__construct();
@@ -180,6 +183,8 @@ class JournalLinkController extends Controller
}
/**
+ * Update object.
+ *
* @param JournalLinkRequest $request
* @param TransactionJournalLink $journalLink
*
diff --git a/app/Api/V1/Controllers/LinkTypeController.php b/app/Api/V1/Controllers/LinkTypeController.php
index 2c7e0c6036..d1dd2e850c 100644
--- a/app/Api/V1/Controllers/LinkTypeController.php
+++ b/app/Api/V1/Controllers/LinkTypeController.php
@@ -40,18 +40,21 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
+ * Class LinkTypeController.
*
- * Class LinkTypeController
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class LinkTypeController extends Controller
{
- /** @var LinkTypeRepositoryInterface */
+ /** @var LinkTypeRepositoryInterface The link type repository */
private $repository;
- /** @var UserRepositoryInterface */
+ /** @var UserRepositoryInterface The user repository */
private $userRepository;
+ /**
+ * LinkTypeController constructor.
+ */
public function __construct()
{
parent::__construct();
@@ -172,6 +175,8 @@ class LinkTypeController extends Controller
}
/**
+ * Update object.
+ *
* @param LinkTypeRequest $request
* @param LinkType $linkType
*
diff --git a/app/Api/V1/Controllers/PiggyBankController.php b/app/Api/V1/Controllers/PiggyBankController.php
index b64a2128b8..0aa3295131 100644
--- a/app/Api/V1/Controllers/PiggyBankController.php
+++ b/app/Api/V1/Controllers/PiggyBankController.php
@@ -39,16 +39,19 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- * TODO order up and down.
- * Class PiggyBankController
+ * Class PiggyBankController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class PiggyBankController extends Controller
{
- /** @var PiggyBankRepositoryInterface */
+ /** @var PiggyBankRepositoryInterface The piggy bank repository */
private $repository;
+ /**
+ * PiggyBankController constructor.
+ */
public function __construct()
{
parent::__construct();
@@ -163,6 +166,8 @@ class PiggyBankController extends Controller
}
/**
+ * Update piggy bank.
+ *
* @param PiggyBankRequest $request
* @param PiggyBank $piggyBank
*
diff --git a/app/Api/V1/Controllers/PreferenceController.php b/app/Api/V1/Controllers/PreferenceController.php
index d17232afff..e7d40c0091 100644
--- a/app/Api/V1/Controllers/PreferenceController.php
+++ b/app/Api/V1/Controllers/PreferenceController.php
@@ -102,6 +102,8 @@ class PreferenceController extends Controller
}
/**
+ * Update a preference.
+ *
* @param PreferenceRequest $request
* @param Preference $preference
*
diff --git a/app/Api/V1/Controllers/RecurrenceController.php b/app/Api/V1/Controllers/RecurrenceController.php
index c80b72d993..10c07b1d02 100644
--- a/app/Api/V1/Controllers/RecurrenceController.php
+++ b/app/Api/V1/Controllers/RecurrenceController.php
@@ -38,14 +38,16 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
- *
* Class RecurrenceController
*/
class RecurrenceController extends Controller
{
- /** @var RecurringRepositoryInterface */
+ /** @var RecurringRepositoryInterface The recurring transaction repository */
private $repository;
+ /**
+ * RecurrenceController constructor.
+ */
public function __construct()
{
parent::__construct();
@@ -155,6 +157,8 @@ class RecurrenceController extends Controller
}
/**
+ * Update single recurrence.
+ *
* @param RecurrenceRequest $request
* @param Recurrence $recurrence
*
diff --git a/app/Api/V1/Controllers/RuleController.php b/app/Api/V1/Controllers/RuleController.php
index 547916d247..d3977bfb2e 100644
--- a/app/Api/V1/Controllers/RuleController.php
+++ b/app/Api/V1/Controllers/RuleController.php
@@ -42,9 +42,12 @@ use League\Fractal\Serializer\JsonApiSerializer;
*/
class RuleController extends Controller
{
- /** @var RuleRepositoryInterface */
+ /** @var RuleRepositoryInterface The rule repository */
private $ruleRepository;
+ /**
+ * RuleController constructor.
+ */
public function __construct()
{
parent::__construct();
@@ -153,6 +156,8 @@ class RuleController extends Controller
}
/**
+ * Update a rule.
+ *
* @param RuleRequest $request
* @param Rule $rule
*
diff --git a/app/Api/V1/Controllers/RuleGroupController.php b/app/Api/V1/Controllers/RuleGroupController.php
index ffa509b3c0..c97fecb22e 100644
--- a/app/Api/V1/Controllers/RuleGroupController.php
+++ b/app/Api/V1/Controllers/RuleGroupController.php
@@ -38,11 +38,17 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
+/**
+ * Class RuleGroupController
+ */
class RuleGroupController extends Controller
{
- /** @var RuleGroupRepositoryInterface */
+ /** @var RuleGroupRepositoryInterface The rule group repository */
private $ruleGroupRepository;
+ /**
+ * RuleGroupController constructor.
+ */
public function __construct()
{
parent::__construct();
@@ -151,6 +157,8 @@ class RuleGroupController extends Controller
}
/**
+ * Update a rule group.
+ *
* @param RuleGroupRequest $request
* @param RuleGroup $ruleGroup
*
diff --git a/app/Api/V1/Controllers/TransactionController.php b/app/Api/V1/Controllers/TransactionController.php
index cb36c610a5..91210a8525 100644
--- a/app/Api/V1/Controllers/TransactionController.php
+++ b/app/Api/V1/Controllers/TransactionController.php
@@ -50,7 +50,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
class TransactionController extends Controller
{
- /** @var JournalRepositoryInterface */
+ /** @var JournalRepositoryInterface The journal repository */
private $repository;
/**
@@ -89,6 +89,8 @@ class TransactionController extends Controller
}
/**
+ * Show all transactions.
+ *
* @param Request $request
*
* @return JsonResponse
@@ -133,6 +135,8 @@ class TransactionController extends Controller
/**
+ * Show a single transaction.
+ *
* @param Request $request
* @param Transaction $transaction
* @param string $include
@@ -173,6 +177,8 @@ class TransactionController extends Controller
}
/**
+ * Store a new transaction.
+ *
* @param TransactionRequest $request
*
* @param JournalRepositoryInterface $repository
@@ -218,6 +224,8 @@ class TransactionController extends Controller
/**
+ * Update a transaction.
+ *
* @param TransactionRequest $request
* @param JournalRepositoryInterface $repository
* @param Transaction $transaction
@@ -262,13 +270,15 @@ class TransactionController extends Controller
}
/**
+ * All the types you can request.
+ *
* @param string $type
*
* @return array
*/
private function mapTypes(string $type): array
{
- $types = [
+ $types = [
'all' => [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::OPENING_BALANCE,
TransactionType::RECONCILIATION,],
'withdrawal' => [TransactionType::WITHDRAWAL,],
@@ -286,11 +296,12 @@ class TransactionController extends Controller
'specials' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION,],
'default' => [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER,],
];
+ $return = $types['default'];
if (isset($types[$type])) {
- return $types[$type];
+ $return = $types[$type];
}
- return $types['default']; // @codeCoverageIgnore
+ return $return;
}
}
diff --git a/app/Api/V1/Controllers/UserController.php b/app/Api/V1/Controllers/UserController.php
index 7871401633..f582513ca0 100644
--- a/app/Api/V1/Controllers/UserController.php
+++ b/app/Api/V1/Controllers/UserController.php
@@ -40,13 +40,14 @@ use League\Fractal\Serializer\JsonApiSerializer;
/**
- * Class UserController
+ * Class UserController.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class UserController extends Controller
{
- /** @var UserRepositoryInterface */
+ /** @var UserRepositoryInterface The user repository */
private $repository;
/**
@@ -119,6 +120,8 @@ class UserController extends Controller
}
/**
+ * Show a single user.
+ *
* @param Request $request
* @param User $user
*
@@ -142,6 +145,8 @@ class UserController extends Controller
}
/**
+ * Store a new user.
+ *
* @param UserRequest $request
*
* @return JsonResponse
@@ -167,6 +172,8 @@ class UserController extends Controller
}
/**
+ * Update a user.
+ *
* @param UserRequest $request
* @param User $user
*
diff --git a/app/Api/V1/Requests/AccountRequest.php b/app/Api/V1/Requests/AccountRequest.php
index 791b560030..db0feadf7e 100644
--- a/app/Api/V1/Requests/AccountRequest.php
+++ b/app/Api/V1/Requests/AccountRequest.php
@@ -30,6 +30,8 @@ class AccountRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -39,6 +41,8 @@ class AccountRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -66,6 +70,8 @@ class AccountRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/AttachmentRequest.php b/app/Api/V1/Requests/AttachmentRequest.php
index de9285ab54..c0cb193e70 100644
--- a/app/Api/V1/Requests/AttachmentRequest.php
+++ b/app/Api/V1/Requests/AttachmentRequest.php
@@ -34,6 +34,8 @@ use FireflyIII\Rules\IsValidAttachmentModel;
class AttachmentRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -43,6 +45,8 @@ class AttachmentRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -57,6 +61,8 @@ class AttachmentRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/AvailableBudgetRequest.php b/app/Api/V1/Requests/AvailableBudgetRequest.php
index 5631f5acc1..0a1fdb6e59 100644
--- a/app/Api/V1/Requests/AvailableBudgetRequest.php
+++ b/app/Api/V1/Requests/AvailableBudgetRequest.php
@@ -29,6 +29,8 @@ namespace FireflyIII\Api\V1\Requests;
class AvailableBudgetRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -38,6 +40,8 @@ class AvailableBudgetRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -51,6 +55,8 @@ class AvailableBudgetRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/BillRequest.php b/app/Api/V1/Requests/BillRequest.php
index f58c977737..cdb6801365 100644
--- a/app/Api/V1/Requests/BillRequest.php
+++ b/app/Api/V1/Requests/BillRequest.php
@@ -33,6 +33,8 @@ class BillRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -42,6 +44,8 @@ class BillRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -64,6 +68,8 @@ class BillRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/BudgetLimitRequest.php b/app/Api/V1/Requests/BudgetLimitRequest.php
index 8ede47cfce..a12ac2ffdc 100644
--- a/app/Api/V1/Requests/BudgetLimitRequest.php
+++ b/app/Api/V1/Requests/BudgetLimitRequest.php
@@ -30,6 +30,8 @@ namespace FireflyIII\Api\V1\Requests;
class BudgetLimitRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -39,6 +41,8 @@ class BudgetLimitRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -52,6 +56,8 @@ class BudgetLimitRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/BudgetRequest.php b/app/Api/V1/Requests/BudgetRequest.php
index e90866d505..707c7b11c2 100644
--- a/app/Api/V1/Requests/BudgetRequest.php
+++ b/app/Api/V1/Requests/BudgetRequest.php
@@ -31,6 +31,8 @@ use FireflyIII\Models\Budget;
class BudgetRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -40,6 +42,8 @@ class BudgetRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -52,6 +56,8 @@ class BudgetRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/CategoryRequest.php b/app/Api/V1/Requests/CategoryRequest.php
index b910674e54..922892103a 100644
--- a/app/Api/V1/Requests/CategoryRequest.php
+++ b/app/Api/V1/Requests/CategoryRequest.php
@@ -31,6 +31,8 @@ use FireflyIII\Models\Category;
class CategoryRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -40,6 +42,8 @@ class CategoryRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -51,6 +55,8 @@ class CategoryRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/CurrencyRequest.php b/app/Api/V1/Requests/CurrencyRequest.php
index 6c63c83ddc..29355bcfbb 100644
--- a/app/Api/V1/Requests/CurrencyRequest.php
+++ b/app/Api/V1/Requests/CurrencyRequest.php
@@ -30,6 +30,8 @@ namespace FireflyIII\Api\V1\Requests;
class CurrencyRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -39,6 +41,8 @@ class CurrencyRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -53,6 +57,8 @@ class CurrencyRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/JournalLinkRequest.php b/app/Api/V1/Requests/JournalLinkRequest.php
index e52d5b7484..d2609eff12 100644
--- a/app/Api/V1/Requests/JournalLinkRequest.php
+++ b/app/Api/V1/Requests/JournalLinkRequest.php
@@ -31,6 +31,8 @@ namespace FireflyIII\Api\V1\Requests;
class JournalLinkRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -40,6 +42,8 @@ class JournalLinkRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -53,6 +57,8 @@ class JournalLinkRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/LinkTypeRequest.php b/app/Api/V1/Requests/LinkTypeRequest.php
index c44dbcb145..3692bc5ea6 100644
--- a/app/Api/V1/Requests/LinkTypeRequest.php
+++ b/app/Api/V1/Requests/LinkTypeRequest.php
@@ -33,6 +33,8 @@ use Illuminate\Validation\Rule;
class LinkTypeRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -42,6 +44,8 @@ class LinkTypeRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -56,6 +60,8 @@ class LinkTypeRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/PiggyBankRequest.php b/app/Api/V1/Requests/PiggyBankRequest.php
index 15a41bda01..5106a93f45 100644
--- a/app/Api/V1/Requests/PiggyBankRequest.php
+++ b/app/Api/V1/Requests/PiggyBankRequest.php
@@ -33,6 +33,8 @@ use FireflyIII\Rules\IsAssetAccountId;
class PiggyBankRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -42,6 +44,8 @@ class PiggyBankRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -58,6 +62,8 @@ class PiggyBankRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/PreferenceRequest.php b/app/Api/V1/Requests/PreferenceRequest.php
index 38c3a39e11..f3439ccfef 100644
--- a/app/Api/V1/Requests/PreferenceRequest.php
+++ b/app/Api/V1/Requests/PreferenceRequest.php
@@ -32,6 +32,8 @@ class PreferenceRequest extends Request
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -40,6 +42,11 @@ class PreferenceRequest extends Request
return auth()->check();
}
+ /**
+ * Get all data from the request.
+ *
+ * @return array
+ */
public function getAll(): array
{
return [
@@ -47,6 +54,11 @@ class PreferenceRequest extends Request
];
}
+ /**
+ * The rules that the incoming request must be matched against.
+ *
+ * @return array
+ */
public function rules(): array
{
return [
diff --git a/app/Api/V1/Requests/RecurrenceRequest.php b/app/Api/V1/Requests/RecurrenceRequest.php
index 032c5d4960..34494a0cce 100644
--- a/app/Api/V1/Requests/RecurrenceRequest.php
+++ b/app/Api/V1/Requests/RecurrenceRequest.php
@@ -37,6 +37,8 @@ class RecurrenceRequest extends Request
use RecurrenceValidation, TransactionValidation;
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -46,6 +48,8 @@ class RecurrenceRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -74,6 +78,8 @@ class RecurrenceRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/RuleGroupRequest.php b/app/Api/V1/Requests/RuleGroupRequest.php
index a8b88601e4..5c56cda869 100644
--- a/app/Api/V1/Requests/RuleGroupRequest.php
+++ b/app/Api/V1/Requests/RuleGroupRequest.php
@@ -33,6 +33,8 @@ use FireflyIII\Models\RuleGroup;
class RuleGroupRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -42,6 +44,8 @@ class RuleGroupRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -54,6 +58,8 @@ class RuleGroupRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/RuleRequest.php b/app/Api/V1/Requests/RuleRequest.php
index e524e0096a..7bc6b2b1be 100644
--- a/app/Api/V1/Requests/RuleRequest.php
+++ b/app/Api/V1/Requests/RuleRequest.php
@@ -32,6 +32,8 @@ use Illuminate\Validation\Validator;
class RuleRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -41,6 +43,8 @@ class RuleRequest extends Request
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -77,6 +81,8 @@ class RuleRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Api/V1/Requests/TransactionRequest.php b/app/Api/V1/Requests/TransactionRequest.php
index 5296f7098f..cbb2f74e71 100644
--- a/app/Api/V1/Requests/TransactionRequest.php
+++ b/app/Api/V1/Requests/TransactionRequest.php
@@ -37,6 +37,8 @@ class TransactionRequest extends Request
use TransactionValidation;
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
@@ -78,6 +80,8 @@ class TransactionRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
@@ -156,6 +160,8 @@ class TransactionRequest extends Request
}
/**
+ * Get transaction data.
+ *
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @return array
diff --git a/app/Api/V1/Requests/UserRequest.php b/app/Api/V1/Requests/UserRequest.php
index 2a4031888f..31cd81f1e2 100644
--- a/app/Api/V1/Requests/UserRequest.php
+++ b/app/Api/V1/Requests/UserRequest.php
@@ -34,28 +34,32 @@ use FireflyIII\User;
class UserRequest extends Request
{
/**
+ * Authorize logged in users.
+ *
* @return bool
*/
public function authorize(): bool
{
+ $result = false;
// Only allow authenticated users
- if (!auth()->check()) {
- return false; // @codeCoverageIgnore
- }
- /** @var User $user */
- $user = auth()->user();
+ if (auth()->check()) {
+ /** @var User $user */
+ $user = auth()->user();
- /** @var UserRepositoryInterface $repository */
- $repository = app(UserRepositoryInterface::class);
+ /** @var UserRepositoryInterface $repository */
+ $repository = app(UserRepositoryInterface::class);
- if (!$repository->hasRole($user, 'owner')) {
- return false; // @codeCoverageIgnore
+ if ($repository->hasRole($user, 'owner')) {
+ $result = true; // @codeCoverageIgnore
+ }
}
- return true;
+ return $result;
}
/**
+ * Get all data from the request.
+ *
* @return array
*/
public function getAll(): array
@@ -70,6 +74,8 @@ class UserRequest extends Request
}
/**
+ * The rules that the incoming request must be matched against.
+ *
* @return array
*/
public function rules(): array
diff --git a/app/Console/Commands/CreateExport.php b/app/Console/Commands/CreateExport.php
index f28cf79bc2..6896b409cf 100644
--- a/app/Console/Commands/CreateExport.php
+++ b/app/Console/Commands/CreateExport.php
@@ -1,5 +1,4 @@
<?php
-
/**
* CreateExport.php
* Copyright (c) 2018 [email protected]
@@ -20,6 +19,8 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @noinspection MultipleReturnStatementsInspection */
+
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
diff --git a/app/Console/Commands/CreateImport.php b/app/Console/Commands/CreateImport.php
index e932bd1a9b..f9a8fb8633 100644
--- a/app/Console/Commands/CreateImport.php
+++ b/app/Console/Commands/CreateImport.php
@@ -1,5 +1,4 @@
<?php
-
/**
* CreateImport.php
* Copyright (c) 2018 [email protected]
@@ -20,6 +19,8 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @noinspection MultipleReturnStatementsInspection */
+
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
diff --git a/app/Console/Commands/DecryptAttachment.php b/app/Console/Commands/DecryptAttachment.php
index afc1692e74..056a638872 100644
--- a/app/Console/Commands/DecryptAttachment.php
+++ b/app/Console/Commands/DecryptAttachment.php
@@ -1,5 +1,4 @@
<?php
-
/**
* DecryptAttachment.php
* Copyright (c) 2018 [email protected]
@@ -20,6 +19,8 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @noinspection MultipleReturnStatementsInspection */
+
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
diff --git a/app/Console/Commands/EncryptFile.php b/app/Console/Commands/EncryptFile.php
index d074897c23..64b19820a5 100644
--- a/app/Console/Commands/EncryptFile.php
+++ b/app/Console/Commands/EncryptFile.php
@@ -1,5 +1,4 @@
<?php
-
/**
* EncryptFile.php
* Copyright (c) 2018 [email protected]
diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php
index 6c0faea5b7..0446f6ccc5 100644
--- a/app/Console/Commands/Import.php
+++ b/app/Console/Commands/Import.php
@@ -1,5 +1,4 @@
-<?php /** @noinspection PhpDynamicAsStaticMethodCallInspection */
-
+<?php
/**
* Import.php
* Copyright (c) 2018 [email protected]
@@ -20,6 +19,9 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @noinspection MultipleReturnStatementsInspection */
+/** @noinspection PhpDynamicAsStaticMethodCallInspection */
+
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
@@ -52,6 +54,8 @@ class Import extends Command
/**
* Run the import routine.
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @throws FireflyException
*/
@@ -102,10 +106,11 @@ class Import extends Command
}
$this->infoLine(sprintf('The import has finished. %d transactions have been imported.', $count));
-
}
/**
+ * Displays an error.
+ *
* @param string $message
* @param array|null $data
*/
@@ -117,6 +122,8 @@ class Import extends Command
}
/**
+ * Displays an informational message.
+ *
* @param string $message
* @param array $data
*/
diff --git a/app/Console/Commands/ScanAttachments.php b/app/Console/Commands/ScanAttachments.php
index 8072af0ce5..ac10dec27f 100644
--- a/app/Console/Commands/ScanAttachments.php
+++ b/app/Console/Commands/ScanAttachments.php
@@ -1,5 +1,4 @@
-<?php /** @noinspection PhpDynamicAsStaticMethodCallInspection */
-
+<?php
/**
* ScanAttachments.php
* Copyright (c) 2018 [email protected]
@@ -20,6 +19,8 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @noinspection PhpDynamicAsStaticMethodCallInspection */
+
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
@@ -63,13 +64,13 @@ class ScanAttachments extends Command
try {
$content = $disk->get($fileName);
} catch (FileNotFoundException $e) {
- $this->error(sprintf('Could not find data for attachment #%d', $attachment->id));
+ $this->error(sprintf('Could not find data for attachment #%d: %s', $attachment->id, $e->getMessage()));
continue;
}
try {
$decrypted = Crypt::decrypt($content);
} catch (DecryptException $e) {
- $this->error(sprintf('Could not decrypt data of attachment #%d', $attachment->id));
+ $this->error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
continue;
}
$tmpfname = tempnam(sys_get_temp_dir(), 'FireflyIII');
diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.php
index b3fcfdee39..37f72b8db4 100644
--- a/app/Console/Commands/UpgradeDatabase.php
+++ b/app/Console/Commands/UpgradeDatabase.php
@@ -1,5 +1,4 @@
-<?php /** @noinspection PhpStaticAsDynamicMethodCallInspection */
-/** @noinspection PhpDynamicAsStaticMethodCallInspection */
+<?php
/**
* UpgradeDatabase.php
@@ -21,6 +20,10 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @noinspection MultipleReturnStatementsInspection */
+/** @noinspection PhpStaticAsDynamicMethodCallInspection */
+/** @noinspection PhpDynamicAsStaticMethodCallInspection */
+
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
@@ -59,6 +62,8 @@ use UnexpectedValueException;
* Class UpgradeDatabase.
*
* Upgrade user database.
+ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class UpgradeDatabase extends Command
{
@@ -94,6 +99,13 @@ class UpgradeDatabase extends Command
$this->info('Firefly III database is up to date.');
}
+ /**
+ * Since it is one routine these warnings make sense and should be supressed.
+ *
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD.NPathComplexity)
+ */
public function migrateBillsToRules(): void
{
foreach (User::get() as $user) {
@@ -104,11 +116,14 @@ class UpgradeDatabase extends Command
$currencyPreference = Preferences::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
if (null === $currencyPreference) {
+ $this->error('User has no currency preference. Impossible.');
+
return;
}
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
if (null === $currency) {
+ $this->line('Fall back to default currency in migrateBillsToRules().');
$currency = app('amount')->getDefaultCurrency();
}
@@ -265,6 +280,9 @@ class UpgradeDatabase extends Command
/**
* Each (asset) account must have a reference to a preferred currency. If the account does not have one, it's forced upon the account.
+ *
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function updateAccountCurrencies(): void
{
@@ -325,6 +343,9 @@ class UpgradeDatabase extends Command
*
* Both source and destination must match the respective currency preference of the related asset account.
* So FF3 must verify all transactions.
+ *
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function updateOtherCurrencies(): void
{
@@ -570,7 +591,11 @@ class UpgradeDatabase extends Command
*
* The transaction that is sent to this function MUST be the source transaction (amount negative).
*
- * Method is long and complex bit I'm taking it for granted.
+ * Method is long and complex but I'll allow it. https://imgur.com/gallery/dVDJiez
+ *
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD.NPathComplexity)
*
* @param Transaction $transaction
*/
diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php
index e419ca7105..eae3998a22 100644
--- a/app/Console/Commands/UpgradeFireflyInstructions.php
+++ b/app/Console/Commands/UpgradeFireflyInstructions.php
@@ -1,5 +1,4 @@
<?php
-
/**
* UpgradeFireflyInstructions.php
* Copyright (c) 2018 [email protected]
diff --git a/app/Console/Commands/UseEncryption.php b/app/Console/Commands/UseEncryption.php
index 0034dde572..df38fff556 100644
--- a/app/Console/Commands/UseEncryption.php
+++ b/app/Console/Commands/UseEncryption.php
@@ -1,5 +1,4 @@
<?php
-
/**
* UseEncryption.php
* Copyright (c) 2018 [email protected]
diff --git a/app/Console/Commands/VerifiesAccessToken.php b/app/Console/Commands/VerifiesAccessToken.php
index c03d456b53..b82beee8ab 100644
--- a/app/Console/Commands/VerifiesAccessToken.php
+++ b/app/Console/Commands/VerifiesAccessToken.php
@@ -1,5 +1,4 @@
<?php
-
/**
* VerifiesAccessToken.php
* Copyright (c) 2018 [email protected]
diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php
index fe30a60e4b..8ca22eef33 100644
--- a/app/Console/Commands/VerifyDatabase.php
+++ b/app/Console/Commands/VerifyDatabase.php
@@ -1,5 +1,4 @@
-<?php /** @noinspection PhpDynamicAsStaticMethodCallInspection */
-
+<?php
/**
* VerifyDatabase.php
* Copyright (c) 2018 [email protected]
@@ -20,6 +19,8 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @noinspection PhpDynamicAsStaticMethodCallInspection */
+
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
@@ -40,12 +41,16 @@ use FireflyIII\User;
use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Builder;
+use Log;
use Preferences;
use Schema;
use stdClass;
/**
* Class VerifyDatabase.
+ *
+ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class VerifyDatabase extends Command
{
@@ -144,9 +149,10 @@ class VerifyDatabase extends Command
}
/**
- * Fix the situation where the matching transactions
- * of a journal somehow have non-matching categories
- * or budgets
+ * Fix the situation where the matching transactions of a journal somehow have non-matching categories or budgets.
+ *
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
private function fixBadMeta(): void
{
@@ -207,6 +213,12 @@ class VerifyDatabase extends Command
}
}
+ /**
+ * Makes sure amounts are stored correctly.
+ *
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
private function fixDoubleAmounts(): void
{
$count = 0;
@@ -256,7 +268,7 @@ class VerifyDatabase extends Command
}
/**
- *
+ * Removes bills from journals that should not have bills.
*/
private function removeBills(): void
{
@@ -396,6 +408,7 @@ class VerifyDatabase extends Command
$objName = Crypt::decrypt($objName);
} catch (DecryptException $e) {
// it probably was not encrypted.
+ Log::debug(sprintf('Not a problem: %s', $e->getMessage()));
}
// also count the transactions:
@@ -433,6 +446,7 @@ class VerifyDatabase extends Command
$objName = Crypt::decrypt($objName);
} catch (DecryptException $e) {
// it probably was not encrypted.
+ Log::debug(sprintf('Not a problem: %s', $e->getMessage()));
}
// also count the transactions:
@@ -571,6 +585,7 @@ class VerifyDatabase extends Command
$objName = Crypt::decrypt($objName);
} catch (DecryptException $e) {
// it probably was not encrypted.
+ Log::debug(sprintf('Not a problem: %s', $e->getMessage()));
}
$line = sprintf(
@@ -598,7 +613,8 @@ class VerifyDatabase extends Command
$sum = (string)$user->transactions()->sum('amount');
if (0 !== bccomp($sum, '0')) {
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
- } else {
+ }
+ if (0 === bccomp($sum, '0')) {
$this->info(sprintf('Amount integrity OK for user #%d', $user->id));
}
}