Some code cleanup courtesy of PHPStorm.

This commit is contained in:
James Cole 2016-01-15 18:21:59 +01:00
parent f69be86c74
commit dcbfe90cf7
8 changed files with 43 additions and 21 deletions

View File

@ -32,6 +32,8 @@ class Kernel extends ConsoleKernel
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void * @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameters)
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {

View File

@ -34,13 +34,13 @@ 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.
* *
* @param \Exception $e * @param Exception $exception
* *
* @return void * @return void
*/ */
public function report(Exception $e) public function report(Exception $exception)
{ {
parent::report($e); parent::report($exception);
} }
/** /**

View File

@ -55,8 +55,6 @@ class CategoryController extends Controller
$start = Navigation::startOfPeriod($start, $range); $start = Navigation::startOfPeriod($start, $range);
$end = new Carbon; $end = new Carbon;
$entries = new Collection; $entries = new Collection;
// chart properties for cache: // chart properties for cache:
$cache = new CacheProperties(); $cache = new CacheProperties();
$cache->addProperty($start); $cache->addProperty($start);
@ -71,26 +69,19 @@ class CategoryController extends Controller
while ($start <= $end) { while ($start <= $end) {
$currentEnd = Navigation::endOfPeriod($start, $range); $currentEnd = Navigation::endOfPeriod($start, $range);
$spent = $this->getSumOfRange($start, $currentEnd, $spentArray);
// get the sum from $spentArray and $earnedArray: $earned = $this->getSumOfRange($start, $currentEnd, $earnedArray);
$spent = $this->getSumOfRange($start, $currentEnd, $spentArray); $date = Navigation::periodShow($start, $range);
$earned = $this->getSumOfRange($start, $currentEnd, $earnedArray);
$date = Navigation::periodShow($start, $range);
$entries->push([clone $start, $date, $spent, $earned]); $entries->push([clone $start, $date, $spent, $earned]);
$start = Navigation::addPeriod($start, $range, 0); $start = Navigation::addPeriod($start, $range, 0);
} }
// limit the set to the last 40:
$entries = $entries->reverse(); $entries = $entries->reverse();
$entries = $entries->slice(0, 48); $entries = $entries->slice(0, 48);
$entries = $entries->reverse(); $entries = $entries->reverse();
$data = $this->generator->all($entries);
$data = $this->generator->all($entries);
$cache->store($data); $cache->store($data);
return Response::json($data); return Response::json($data);
} }

View File

@ -41,6 +41,8 @@ class ReportController extends Controller
* @param Carbon $end * @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
* *
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function yearInOut(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts) public function yearInOut(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts)

View File

@ -337,6 +337,8 @@ class RuleController extends Controller
/** /**
* @param Rule $rule * @param Rule $rule
*
* @return array
*/ */
private function getCurrentActions(Rule $rule) private function getCurrentActions(Rule $rule)
{ {

View File

@ -27,6 +27,8 @@ class TagRepository implements TagRepositoryInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param Tag $tag * @param Tag $tag
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
*
* @return boolean * @return boolean
*/ */
public function connect(TransactionJournal $journal, Tag $tag) public function connect(TransactionJournal $journal, Tag $tag)

View File

@ -29,9 +29,9 @@ class Amount
*/ */
public function formatAnything(TransactionCurrency $format, $amount, $coloured = true) public function formatAnything(TransactionCurrency $format, $amount, $coloured = true)
{ {
$locale = setlocale(LC_MONETARY, 0); $locale = setlocale(LC_MONETARY, 0);
$a = new NumberFormatter($locale, NumberFormatter::CURRENCY); $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
$result = $a->formatCurrency($amount, $format->code); $result = $formatter->formatCurrency($amount, $format->code);
if ($coloured === true) { if ($coloured === true) {
if ($amount == 0) { if ($amount == 0) {

View File

@ -32,6 +32,8 @@ class FireflyValidator extends Validator
* @param array $rules * @param array $rules
* @param array $messages * @param array $messages
* @param array $customAttributes * @param array $customAttributes
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // inherited from Laravel.
*/ */
public function __construct(TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = []) 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. // loop all rule-triggers.
// check if rule-value matches the thing. // check if rule-value matches the thing.
if (is_array($this->data['rule-trigger'])) { if (is_array($this->data['rule-trigger'])) {
$name = isset($this->data['rule-trigger'][$index]) ? $this->data['rule-trigger'][$index] : 'invalid'; $name = $this->getRuleTriggerName($index);
$value = isset($this->data['rule-trigger-value'][$index]) ? $this->data['rule-trigger-value'][$index] : false; $value = $this->getRuleTriggerValue($index);
switch ($name) { switch ($name) {
default: default:
return true; return true;
@ -406,5 +408,26 @@ class FireflyValidator extends Validator
return true; return 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] : '';
}
} }