Various code clean up.

This commit is contained in:
James Cole
2017-08-12 10:27:45 +02:00
parent a3a416b5e2
commit 9803932324
99 changed files with 322 additions and 24 deletions

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/**
* UseEncryption.php
* Copyright (c) 2017 thegrumpydictator@gmail.com

View File

@@ -138,7 +138,7 @@ class HomeController extends Controller
}
return view(
'index', compact('count', 'title', 'subTitle', 'mainTitleIcon', 'transactions', 'showDepositsFrontpage', 'billCount')
'index', compact('count', 'subTitle', 'transactions', 'showDepositsFrontpage', 'billCount')
);
}

View File

@@ -156,7 +156,7 @@ class TagController extends Controller
Session::flash('gaEventCategory', 'tags');
Session::flash('gaEventAction', 'edit');
return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon', 'tagOptions', 'apiKey'));
return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon', 'apiKey'));
}
/**

View File

@@ -131,10 +131,9 @@ class MassController extends Controller
$filtered = new Collection;
$messages = [];
/**
* @var int $index
* @var TransactionJournal $journal
*/
foreach ($journals as $index => $journal) {
foreach ($journals as $journal) {
$sources = $journal->sourceAccountList();
$destinations = $journal->destinationAccountList();
if ($sources->count() > 1) {

View File

@@ -114,7 +114,7 @@ class SplitController extends Controller
'transactions.split.edit',
compact(
'subTitleIcon', 'currencies', 'optionalFields',
'preFilled', 'subTitle', 'amount', 'sourceAccounts', 'uploadSize', 'destinationAccounts', 'assetAccounts',
'preFilled', 'subTitle', 'uploadSize', 'assetAccounts',
'budgets', 'journal'
)
);

View File

@@ -260,8 +260,8 @@ class CsvProcessor implements FileProcessorInterface
private function specifics(array $row): array
{
$config = $this->job->configuration;
//
foreach ($config['specifics'] as $name => $enabled) {
$names = array_keys($config['specifics']);
foreach ($names as $name) {
if (!in_array($name, $this->validSpecifics)) {
throw new FireflyException(sprintf('"%s" is not a valid class name', $name));

View File

@@ -252,12 +252,11 @@ class ImportStorage
/**
* @param ImportJournal $importJournal
* @param Account $account
* @param TransactionCurrency $localCurrency
*
* @return int|null
*/
private function getForeignCurrencyId(ImportJournal $importJournal, Account $account, TransactionCurrency $localCurrency): ?int
private function getForeignCurrencyId(ImportJournal $importJournal, TransactionCurrency $localCurrency): ?int
{
// get journal currency, if any:
$currency = $importJournal->getCurrency()->getTransactionCurrency();
@@ -394,7 +393,7 @@ class ImportStorage
$asset = $importJournal->asset->getAccount();
$amount = $importJournal->getAmount();
$currency = $this->getCurrency($importJournal, $asset);
$foreignCurrencyId = $this->getForeignCurrencyId($importJournal, $asset, $currency);
$foreignCurrencyId = $this->getForeignCurrencyId($importJournal, $currency);
$date = $importJournal->getDate($this->dateFormat);
$transactionType = $this->getTransactionType($amount);
$opposing = $this->getOpposingAccount($importJournal->opposing, $amount);

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/**

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/**

View File

@@ -206,7 +206,8 @@ class AccountTasker implements AccountTaskerInterface
$expenses[$opposingId]['count']++;
}
// do averages:
foreach ($expenses as $key => $entry) {
$keys = array_keys($expenses);
foreach ($keys as $key) {
if ($expenses[$key]['count'] > 1) {
$expenses[$key]['average'] = bcdiv($expenses[$key]['sum'], strval($expenses[$key]['count']));
}

View File

@@ -134,7 +134,8 @@ class Initial implements ConfigurationInterface
{
// loop specifics.
if (isset($data['specifics']) && is_array($data['specifics'])) {
foreach ($data['specifics'] as $name => $enabled) {
$names = array_keys($data['specifics']);
foreach ($names as $name) {
// verify their content.
$className = sprintf('FireflyIII\Import\Specifics\%s', $name);
if (class_exists($className)) {

View File

@@ -90,10 +90,12 @@ class Map implements ConfigurationInterface
}
}
}
foreach ($this->data as $index => $entry) {
$setIndexes = array_keys($this->data);
foreach ($setIndexes as $index) {
$this->data[$index]['values'] = array_unique($this->data[$index]['values']);
asort($this->data[$index]['values']);
}
unset($setIndexes);
// save number of rows, thus number of steps, in job:
$steps = $rowIndex * 5;
@@ -233,8 +235,8 @@ class Map implements ConfigurationInterface
{
// run specifics here:
// and this is the point where the specifix go to work.
foreach ($this->configuration['specifics'] as $name => $enabled) {
$names = array_keys($this->configuration['specifics']);
foreach ($names as $name) {
if (!in_array($name, $this->validSpecifics)) {
throw new FireflyException(sprintf('"%s" is not a valid class name', $name));
}

View File

@@ -228,7 +228,8 @@ class Roles implements ConfigurationInterface
*/
private function processSpecifics(array $row): array
{
foreach ($this->job->configuration['specifics'] as $name => $enabled) {
$names = array_keys($this->configuration['specifics']);
foreach ($names as $name) {
/** @var SpecificInterface $specific */
$specific = app('FireflyIII\Import\Specifics\\' . $name);
$row = $specific->run($row);

View File

@@ -119,7 +119,7 @@ class Search implements SearchInterface
// Filter transactions that match the given triggers.
$filtered = $set->filter(
function (Transaction $transaction) use ($words) {
function (Transaction $transaction) {
if ($this->matchModifiers($transaction)) {
return $transaction;
@@ -237,7 +237,7 @@ class Search implements SearchInterface
return false;
}
foreach ($needle as $what) {
if (($pos = strpos($haystack, $what)) !== false) {
if (strpos($haystack, $what) !== false) {
return true;
}
}