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
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameters)
*/
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.
*
* @param \Exception $e
* @param Exception $exception
*
* @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);
$end = new Carbon;
$entries = new Collection;
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
@ -71,26 +69,19 @@ class CategoryController extends Controller
while ($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);
}

View File

@ -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)

View File

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

View File

@ -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)

View File

@ -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) {

View File

@ -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 Validator
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] : '';
}
}