Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Some code cleanup courtesy of PHPStorm.
James Coledcbfe90cf710
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.phpindex 9579812620..488b36c74f 100755--- a/app/Console/Kernel.php+++ b/app/Console/Kernel.php@@ -32,6 +32,8 @@ class Kernel extends ConsoleKernel** @param \Illuminate\Console\Scheduling\Schedule $schedule* @return void+ *+ * @SuppressWarnings(PHPMD.UnusedFormalParameters)*/protected function schedule(Schedule $schedule){diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 7913d17568..8216857d24 100755--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -34,13 +34,13 @@ class Handler extends ExceptionHandler** This is a great spot to send exceptions to Sentry, Bugsnag, etc.*- * @param \Exception $e+ * @param Exception $exception** @return void*/- public function report(Exception $e)+ public function report(Exception $exception){- parent::report($e);+ parent::report($exception);}/**diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex eb91f28e00..199319e62b 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -55,8 +55,6 @@ class CategoryController extends Controller$start = Navigation::startOfPeriod($start, $range);$end = new Carbon;$entries = new Collection;--// chart properties for cache:$cache = new CacheProperties();$cache->addProperty($start);@@ -71,26 +69,19 @@ class CategoryController extends Controllerwhile ($start <= $end) {$currentEnd = Navigation::endOfPeriod($start, $range);-- // get the sum from $spentArray and $earnedArray:- $spent = $this->getSumOfRange($start, $currentEnd, $spentArray);- $earned = $this->getSumOfRange($start, $currentEnd, $earnedArray);-- $date = Navigation::periodShow($start, $range);+ $spent = $this->getSumOfRange($start, $currentEnd, $spentArray);+ $earned = $this->getSumOfRange($start, $currentEnd, $earnedArray);+ $date = Navigation::periodShow($start, $range);$entries->push([clone $start, $date, $spent, $earned]);$start = Navigation::addPeriod($start, $range, 0);}- // limit the set to the last 40:$entries = $entries->reverse();$entries = $entries->slice(0, 48);$entries = $entries->reverse();-- $data = $this->generator->all($entries);+ $data = $this->generator->all($entries);$cache->store($data);return Response::json($data);--}diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.phpindex 545fe46d7a..97bb03be11 100644--- a/app/Http/Controllers/Chart/ReportController.php+++ b/app/Http/Controllers/Chart/ReportController.php@@ -41,6 +41,8 @@ class ReportController extends Controller* @param Carbon $end* @param Collection $accounts*+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)+ ** @return \Illuminate\Http\JsonResponse*/public function yearInOut(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts)diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.phpindex 9777a8f74a..03dd0c17f3 100644--- a/app/Http/Controllers/RuleController.php+++ b/app/Http/Controllers/RuleController.php@@ -337,6 +337,8 @@ class RuleController extends Controller/*** @param Rule $rule+ *+ * @return array*/private function getCurrentActions(Rule $rule){diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex ccdb2d9dae..f13f5bcc92 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -27,6 +27,8 @@ class TagRepository implements TagRepositoryInterface* @param TransactionJournal $journal* @param Tag $tag*+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.+ ** @return boolean*/public function connect(TransactionJournal $journal, Tag $tag)diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex 00a13f85bd..72bb329ad7 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -29,9 +29,9 @@ class Amount*/public function formatAnything(TransactionCurrency $format, $amount, $coloured = true){- $locale = setlocale(LC_MONETARY, 0);- $a = new NumberFormatter($locale, NumberFormatter::CURRENCY);- $result = $a->formatCurrency($amount, $format->code);+ $locale = setlocale(LC_MONETARY, 0);+ $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);+ $result = $formatter->formatCurrency($amount, $format->code);if ($coloured === true) {if ($amount == 0) {diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex 728881a19d..90e65fb36a 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -32,6 +32,8 @@ class FireflyValidator extends Validator* @param array $rules* @param array $messages* @param array $customAttributes+ *+ * @SuppressWarnings(PHPMD.ExcessiveParameterList) // inherited from Laravel.*/public function __construct(TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = []){@@ -52,8 +54,8 @@ class FireflyValidator extends Validator// loop all rule-triggers.// check if rule-value matches the thing.if (is_array($this->data['rule-trigger'])) {- $name = isset($this->data['rule-trigger'][$index]) ? $this->data['rule-trigger'][$index] : 'invalid';- $value = isset($this->data['rule-trigger-value'][$index]) ? $this->data['rule-trigger-value'][$index] : false;+ $name = $this->getRuleTriggerName($index);+ $value = $this->getRuleTriggerValue($index);switch ($name) {default:return true;@@ -406,5 +408,26 @@ class FireflyValidator extends Validatorreturn true;}++ /**+ * @param int $index+ *+ * @return string+ */+ private function getRuleTriggerName($index)+ {+ return isset($this->data['rule-trigger'][$index]) ? $this->data['rule-trigger'][$index] : 'invalid';++ }++ /**+ * @param int $index+ *+ * @return string+ */+ private function getRuleTriggerValue($index)+ {+ return isset($this->data['rule-trigger-value'][$index]) ? $this->data['rule-trigger-value'][$index] : '';+ }}