Code cleanup

This commit is contained in:
James Cole
2018-04-02 15:10:40 +02:00
parent fa7ab45a40
commit a3c34e6b3c
151 changed files with 802 additions and 990 deletions

View File

@@ -113,7 +113,7 @@ class AutoCompleteController extends Controller
$set = $collector->getJournals()->pluck('description', 'journal_id')->toArray();
$return = [];
foreach ($set as $id => $description) {
$id = intval($id);
$id = (int)$id;
if ($id !== $except->id) {
$return[] = [
'id' => $id,

View File

@@ -123,7 +123,7 @@ class BoxController extends Controller
$set = $collector->getJournals();
/** @var Transaction $transaction */
foreach ($set as $transaction) {
$currencyId = intval($transaction->transaction_currency_id);
$currencyId = (int)$transaction->transaction_currency_id;
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes[$currencyId] = bcadd($incomes[$currencyId], $transaction->transaction_amount);
$sums[$currencyId] = $sums[$currencyId] ?? '0';

View File

@@ -50,9 +50,6 @@ class ExchangeController extends Controller
$rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date);
if (null === $rate->id) {
Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
@@ -69,7 +66,7 @@ class ExchangeController extends Controller
$return['amount'] = null;
if (null !== $request->get('amount')) {
// assume amount is in "from" currency:
$return['amount'] = bcmul($request->get('amount'), strval($rate->rate), 12);
$return['amount'] = bcmul($request->get('amount'), (string)$rate->rate, 12);
// round to toCurrency decimal places:
$return['amount'] = round($return['amount'], $toCurrency->decimal_places);
}

View File

@@ -36,7 +36,7 @@ class FrontpageController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function piggyBanks(PiggyBankRepositoryInterface $repository)
{

View File

@@ -76,14 +76,17 @@ class IntroController
$routeKey = str_replace('.', '_', $route);
Log::debug(sprintf('Has outro step for route %s', $routeKey));
$elements = config(sprintf('intro.%s', $routeKey));
if (!is_array($elements)) {
if (!\is_array($elements)) {
return false;
}
$hasStep = array_key_exists('outro', $elements);
Log::debug('Elements is array', $elements);
Log::debug('Keys is', array_keys($elements));
Log::debug(sprintf('Keys has "outro": %s', var_export(in_array('outro', array_keys($elements)), true)));
Log::debug(sprintf('Keys has "outro": %s', var_export($hasStep, true)));
return in_array('outro', array_keys($elements));
return $hasStep;
}
/**