Browse Source

Clean up code.

pull/17/head
James Cole 4 years ago
parent
commit
682b08a51c
No known key found for this signature in database GPG Key ID: BDE6667570EADBD5
  1. 1
      app/Console/AutoImports.php
  2. 3
      app/Http/Controllers/AutoImportController.php
  3. 3
      app/Http/Controllers/AutoUploadController.php
  4. 4
      app/Http/Controllers/DebugController.php
  5. 2
      app/Http/Controllers/Import/CSV/RoleController.php
  6. 1
      app/Http/Controllers/Import/ConfigurationController.php
  7. 1
      app/Http/Controllers/Import/ConversionController.php
  8. 2
      app/Http/Controllers/Import/DownloadController.php
  9. 1
      app/Http/Controllers/Import/MapController.php
  10. 6
      app/Http/Controllers/Import/Nordigen/SelectionController.php
  11. 4
      app/Http/Controllers/Import/Spectre/ConnectionController.php
  12. 2
      app/Http/Controllers/Import/SubmitController.php
  13. 2
      app/Http/Request/Request.php
  14. 1
      app/Http/Request/SelectionRequest.php
  15. 2
      app/Services/CSV/Configuration/Configuration.php
  16. 2
      app/Services/CSV/Conversion/Routine/ColumnValueConverter.php
  17. 8
      app/Services/CSV/Converter/Amount.php
  18. 2
      app/Services/CSV/Converter/CleanId.php
  19. 2
      app/Services/CSV/Converter/CleanInteger.php
  20. 2
      app/Services/CSV/Converter/CleanString.php
  21. 4
      app/Services/CSV/Converter/Date.php
  22. 2
      app/Services/CSV/Converter/Iban.php
  23. 2
      app/Services/CSV/Converter/TagsComma.php
  24. 2
      app/Services/CSV/Converter/TagsSpace.php
  25. 1
      app/Services/Nordigen/Request/GetTransactionsRequest.php
  26. 2
      app/Services/Nordigen/Services/AccountInformationCollector.php
  27. 1
      app/Services/Spectre/Conversion/Routine/GenerateTransactions.php
  28. 2
      app/Services/Spectre/Model/Customer.php
  29. 1
      app/Services/Spectre/Request/ListConnectionsRequest.php
  30. 1
      app/Services/Storage/StorageService.php
  31. 2
      config/app.php
  32. 4
      config/database.php
  33. 6
      config/session.php

1
app/Console/AutoImports.php

@ -297,7 +297,6 @@ trait AutoImports
/**
* @param Configuration $configuration
* @param array $transactions
*/
private function startImport(Configuration $configuration): void
{

3
app/Http/Controllers/AutoImportController.php

@ -76,9 +76,6 @@ class AutoImportController extends Controller
return ' ';
}
/**
* @inheritDoc
*/
public function line(string $string)
{
echo sprintf("%s: %s\n", date('Y-m-d H:i:s'), $string);

3
app/Http/Controllers/AutoUploadController.php

@ -64,9 +64,6 @@ class AutoUploadController extends Controller
return ' ';
}
/**
* @inheritDoc
*/
public function line(string $string)
{
echo sprintf("%s: %s\n", date('Y-m-d H:i:s'), $string);

4
app/Http/Controllers/DebugController.php

@ -29,10 +29,6 @@ use Artisan;
use Carbon\Carbon;
use DB;
use Exception;
use FireflyConfig;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request;
use Illuminate\View\View;

2
app/Http/Controllers/Import/CSV/RoleController.php

@ -87,7 +87,7 @@ class RoleController extends Controller
$examples = RoleService::getExampleData($content, $configuration);
// submit mapping from config.
$mapping = base64_encode(json_encode($configuration->getMapping(), JSON_THROW_ON_ERROR, 512));
$mapping = base64_encode(json_encode($configuration->getMapping(), JSON_THROW_ON_ERROR));
// roles
$roles = config('csv.import_roles');

1
app/Http/Controllers/Import/ConfigurationController.php

@ -300,7 +300,6 @@ class ConfigurationController extends Controller
$return = [];
Log::debug('Now creating Spectre account lists.');
/** @var SpectreAccount $spectreAccount */
foreach ($spectre as $spectreAccount) {
Log::debug(sprintf('Now working on Spectre account "%s": "%s"', $spectreAccount->name, $spectreAccount->id));
$iban = $spectreAccount->iban;

1
app/Http/Controllers/Import/ConversionController.php

@ -221,7 +221,6 @@ class ConversionController extends Controller
* @param Request $request
*
* @return JsonResponse
* @throws JsonException
*/
public function status(Request $request): JsonResponse
{

2
app/Http/Controllers/Import/DownloadController.php

@ -57,7 +57,7 @@ class DownloadController extends Controller
$array = $configuration->toArray();
$result = json_encode($array, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT, 512);
$result = json_encode($array, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
$response = response($result);
$name = sprintf('import_config_%s.json', date('Y-m-d'));

1
app/Http/Controllers/Import/MapController.php

@ -66,7 +66,6 @@ class MapController extends Controller
/**
* @return Factory|View
* @throws Exception
* @throws FileNotFoundException
*/
public function index()

6
app/Http/Controllers/Import/Nordigen/SelectionController.php

@ -88,7 +88,11 @@ class SelectionController extends Controller
}
/**
* @param Request $request
* @param SelectionRequest $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws ImporterErrorException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function postIndex(SelectionRequest $request)
{

4
app/Http/Controllers/Import/Spectre/ConnectionController.php

@ -110,7 +110,7 @@ class ConnectionController extends Controller
// save config
$json = '[]';
try {
$json = json_encode($configuration->toArray(), JSON_THROW_ON_ERROR, 512);
$json = json_encode($configuration->toArray(), JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
Log::error($e->getMessage());
}
@ -170,7 +170,7 @@ class ConnectionController extends Controller
// save config
$json = '[]';
try {
$json = json_encode($configuration->toArray(), JSON_THROW_ON_ERROR, 512);
$json = json_encode($configuration->toArray(), JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
Log::error($e->getMessage());
}

2
app/Http/Controllers/Import/SubmitController.php

@ -104,7 +104,6 @@ class SubmitController extends Controller
* @param Request $request
*
* @return JsonResponse
* @throws JsonException
*/
public function status(Request $request): JsonResponse
{
@ -128,7 +127,6 @@ class SubmitController extends Controller
* @param Request $request
*
* @return JsonResponse
* @throws ImporterErrorException
*/
public function start(Request $request): JsonResponse
{

2
app/Http/Request/Request.php

@ -38,7 +38,7 @@ use Log;
class Request extends FormRequest
{
/**
* @param string $value
* @param string|null $value
*
* @return bool
*/

1
app/Http/Request/SelectionRequest.php

@ -25,7 +25,6 @@ declare(strict_types=1);
namespace App\Http\Request;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Validation\Validator;
/**

2
app/Services/CSV/Configuration/Configuration.php

@ -601,7 +601,7 @@ class Configuration
}
/**
* @return int
* @return int|null
*/
public function getDefaultAccount(): ?int
{

2
app/Services/CSV/Conversion/Routine/ColumnValueConverter.php

@ -171,7 +171,7 @@ class ColumnValueConverter
{
if (is_array($value)) {
try {
return json_encode($value, JSON_THROW_ON_ERROR, 512);
return json_encode($value, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
throw new ImporterErrorException($e->getMessage(), 0, $e);
}

8
app/Services/CSV/Converter/Amount.php

@ -109,7 +109,7 @@ class Amount implements ConverterInterface
$value = str_replace($search, '', $value);
Log::debug(sprintf('No decimal character found. Converted amount from "%s" to "%s".', $original, $value));
}
if (0 === strpos($value, '.')) {
if (str_starts_with($value, '.')) {
$value = '0' . $value;
}
@ -136,7 +136,7 @@ class Amount implements ConverterInterface
*/
private function stripAmount(string $value): string
{
if (0 === strpos($value, '--')) {
if (str_starts_with($value, '--')) {
$value = substr($value, 2);
}
// have to strip the € because apparantly the Postbank (DE) thinks "1.000,00 €" is a normal way to format a number.
@ -145,7 +145,7 @@ class Amount implements ConverterInterface
$value = trim((string) str_replace(['€', 'EUR'], '', $value));
$str = preg_replace('/[^\-().,0-9 ]/', '', $value);
$len = strlen($str);
if (0 === strpos($str, '(') && ')' === $str[$len - 1]) {
if (str_starts_with($str, '(') && ')' === $str[$len - 1]) {
$str = '-' . substr($str, 1, $len - 2);
}
$str = trim($str);
@ -223,7 +223,7 @@ class Amount implements ConverterInterface
*
* @param string $value
*
* @return string
* @return string|null
*/
private function findFromLeft(string $value): ?string
{

2
app/Services/CSV/Converter/CleanId.php

@ -37,7 +37,7 @@ class CleanId implements ConverterInterface
*
* @param $value
*
* @return mixed
* @return int|null
*
*/
public function convert($value)

2
app/Services/CSV/Converter/CleanInteger.php

@ -36,7 +36,7 @@ class CleanInteger implements ConverterInterface
*
* @param $value
*
* @return mixed
* @return int
*
*/
public function convert($value)

2
app/Services/CSV/Converter/CleanString.php

@ -35,7 +35,7 @@ class CleanString implements ConverterInterface
*
* @param $value
*
* @return mixed
* @return string
*
*/
public function convert($value)

4
app/Services/CSV/Converter/Date.php

@ -54,7 +54,7 @@ class Date implements ConverterInterface
*
* @param $value
*
* @return mixed
* @return string
*
*/
public function convert($value)
@ -97,7 +97,7 @@ class Date implements ConverterInterface
/**
* @param string $format
* @return array|string[]
* @return array
*/
public function splitLocaleFormat(string $format): array
{

2
app/Services/CSV/Converter/Iban.php

@ -38,7 +38,7 @@ class Iban implements ConverterInterface
*
* @param $value
*
* @return mixed
* @return array|string|string[]
*
*/
public function convert($value)

2
app/Services/CSV/Converter/TagsComma.php

@ -36,7 +36,7 @@ class TagsComma implements ConverterInterface
*
* @param $value
*
* @return mixed
* @return string[]
*
*/
public function convert($value)

2
app/Services/CSV/Converter/TagsSpace.php

@ -36,7 +36,7 @@ class TagsSpace implements ConverterInterface
*
* @param $value
*
* @return mixed
* @return string[]
*
*/
public function convert($value)

1
app/Services/Nordigen/Request/GetTransactionsRequest.php

@ -65,7 +65,6 @@ class GetTransactionsRequest extends Request
$response = $this->authenticatedGet();
$keys = ['booked', 'pending'];
$return = [];
/** @var string $key */
foreach ($keys as $key) {
if (array_key_exists($key, $response['transactions'])) {
$set = $response['transactions'][$key];

2
app/Services/Nordigen/Services/AccountInformationCollector.php

@ -133,7 +133,7 @@ class AccountInformationCollector
*/
private static function getBalanceDetails(Account $account): Account
{
Log::debug(sprintf(sprintf('Now in %s(%s)', __METHOD__, $account->getIdentifier())));
Log::debug(sprintf('Now in %s(%s)', __METHOD__, $account->getIdentifier()));
$url = config('nordigen.url');
$accessToken = TokenManager::getAccessToken();

1
app/Services/Spectre/Conversion/Routine/GenerateTransactions.php

@ -113,7 +113,6 @@ class GenerateTransactions
* @param array $entry
*
* @return array
* @throws ImporterErrorException
*/
private function generateTransaction(array $entry): array
{

2
app/Services/Spectre/Model/Customer.php

@ -30,7 +30,7 @@ namespace App\Services\Spectre\Model;
*/
class Customer
{
/** @var int */
/** @var string */
public string $id;
/** @var string */
public string $identifier;

1
app/Services/Spectre/Request/ListConnectionsRequest.php

@ -58,7 +58,6 @@ class ListConnectionsRequest extends Request
/**
* @inheritDoc
* @throws JsonException
*/
public function get(): Response
{

1
app/Services/Storage/StorageService.php

@ -84,7 +84,6 @@ class StorageService
* @param string $name
* @param bool $convert
* @return string
* @throws FileNotFoundException
*/
public static function getContent(string $name, bool $convert = false): string
{

2
config/app.php

@ -79,7 +79,7 @@ return [
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL', null),
'asset_url' => env('ASSET_URL'),
/*
|--------------------------------------------------------------------------

4
config/database.php

@ -154,7 +154,7 @@ return [
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
@ -162,7 +162,7 @@ return [
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],

6
config/session.php

@ -95,7 +95,7 @@ return [
|
*/
'connection' => env('SESSION_CONNECTION', null),
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
@ -121,7 +121,7 @@ return [
|
*/
'store' => env('SESSION_STORE', null),
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
@ -176,7 +176,7 @@ return [
|
*/
'domain' => env('SESSION_DOMAIN', null),
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------

Loading…
Cancel
Save