mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup
This commit is contained in:
@@ -60,7 +60,7 @@ class BunqConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function configureJob(array $data): bool
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
||||
@@ -94,7 +94,7 @@ class BunqConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$config = $this->getConfig();
|
||||
@@ -107,9 +107,8 @@ class BunqConfigurator implements ConfiguratorInterface
|
||||
/** @var HaveAccounts $class */
|
||||
$class = app(HaveAccounts::class);
|
||||
$class->setJob($this->job);
|
||||
$data = $class->getData();
|
||||
|
||||
return $data;
|
||||
return $class->getData();
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -122,7 +121,7 @@ class BunqConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
||||
@@ -153,7 +152,7 @@ class BunqConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function isJobConfigured(): bool
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
||||
|
||||
@@ -84,7 +84,7 @@ class FileConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function configureJob(array $data): bool
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
/** @var ConfigurationInterface $object */
|
||||
@@ -105,7 +105,7 @@ class FileConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call getNextData() without a job.');
|
||||
}
|
||||
/** @var ConfigurationInterface $object */
|
||||
@@ -122,7 +122,7 @@ class FileConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call getNextView() without a job.');
|
||||
}
|
||||
$config = $this->getConfig();
|
||||
@@ -149,7 +149,7 @@ class FileConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function getWarningMessage(): string
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call getWarningMessage() without a job.');
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class FileConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function isJobConfigured(): bool
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call isJobConfigured() without a job.');
|
||||
}
|
||||
$config = $this->getConfig();
|
||||
|
||||
@@ -60,7 +60,7 @@ class SpectreConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function configureJob(array $data): bool
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
||||
@@ -93,7 +93,7 @@ class SpectreConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$config = $this->getConfig();
|
||||
@@ -116,9 +116,8 @@ class SpectreConfigurator implements ConfiguratorInterface
|
||||
/** @var HaveAccounts $class */
|
||||
$class = app(HaveAccounts::class);
|
||||
$class->setJob($this->job);
|
||||
$data = $class->getData();
|
||||
|
||||
return $data;
|
||||
return $class->getData();
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -131,7 +130,7 @@ class SpectreConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
||||
@@ -166,7 +165,7 @@ class SpectreConfigurator implements ConfiguratorInterface
|
||||
*/
|
||||
public function isJobConfigured(): bool
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call configureJob() without a job.');
|
||||
}
|
||||
$stage = $this->getConfig()['stage'] ?? 'initial';
|
||||
|
||||
@@ -47,7 +47,7 @@ class Amount implements ConverterInterface
|
||||
}
|
||||
Log::debug(sprintf('Start with amount "%s"', $value));
|
||||
$original = $value;
|
||||
$value = strval($value);
|
||||
$value = (string)$value;
|
||||
$value = $this->stripAmount($value);
|
||||
$len = strlen($value);
|
||||
$decimalPosition = $len - 3;
|
||||
@@ -69,7 +69,7 @@ class Amount implements ConverterInterface
|
||||
}
|
||||
|
||||
// decimal character still null? Search from the left for '.',',' or ' '.
|
||||
if (is_null($decimal)) {
|
||||
if (null === $decimal) {
|
||||
Log::debug('Decimal is still NULL, probably number with >2 decimals. Search for a dot.');
|
||||
$res = strrpos($value, '.');
|
||||
if (!(false === $res)) {
|
||||
@@ -99,9 +99,7 @@ class Amount implements ConverterInterface
|
||||
Log::debug(sprintf('No decimal character found. Converted amount from "%s" to "%s".', $original, $value));
|
||||
}
|
||||
|
||||
$number = strval(number_format(round(floatval($value), 12), 12, '.', ''));
|
||||
|
||||
return $number;
|
||||
return strval(number_format(round(floatval($value), 12), 12, '.', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,9 +46,9 @@ class CsvProcessor implements FileProcessorInterface
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
/** @var array */
|
||||
private $validConverters = [];
|
||||
private $validConverters;
|
||||
/** @var array */
|
||||
private $validSpecifics = [];
|
||||
private $validSpecifics;
|
||||
|
||||
/**
|
||||
* FileProcessorInterface constructor.
|
||||
@@ -67,7 +67,7 @@ class CsvProcessor implements FileProcessorInterface
|
||||
*/
|
||||
public function getObjects(): Collection
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call getObjects() without a job.');
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class CsvProcessor implements FileProcessorInterface
|
||||
*/
|
||||
public function run(): bool
|
||||
{
|
||||
if (is_null($this->job)) {
|
||||
if (null === $this->job) {
|
||||
throw new FireflyException('Cannot call run() without a job.');
|
||||
}
|
||||
Log::debug('Now in CsvProcessor run(). Job is now running...');
|
||||
@@ -128,7 +128,7 @@ class CsvProcessor implements FileProcessorInterface
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
public function setExtendedStatus(array $array)
|
||||
public function setExtendedStatus(array $array): void
|
||||
{
|
||||
$this->repository->setExtendedStatus($this->job, $array);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class CsvProcessor implements FileProcessorInterface
|
||||
$config = $this->getConfig();
|
||||
$reader = Reader::createFromString($content);
|
||||
$delimiter = $config['delimiter'] ?? ',';
|
||||
$hasHeaders = isset($config['has-headers']) ? $config['has-headers'] : false;
|
||||
$hasHeaders = $config['has-headers'] ?? false;
|
||||
$offset = 0;
|
||||
if ('tab' === $delimiter) {
|
||||
$delimiter = "\t"; // @codeCoverageIgnore
|
||||
@@ -312,7 +312,7 @@ class CsvProcessor implements FileProcessorInterface
|
||||
* @var string $value
|
||||
*/
|
||||
foreach ($row as $rowIndex => $value) {
|
||||
$value = trim(strval($value));
|
||||
$value = trim((string)$value);
|
||||
if (strlen($value) > 0) {
|
||||
$annotated = $this->annotateValue($rowIndex, $value);
|
||||
Log::debug('Annotated value', $annotated);
|
||||
@@ -320,7 +320,7 @@ class CsvProcessor implements FileProcessorInterface
|
||||
}
|
||||
}
|
||||
// set some extra info:
|
||||
$importAccount = intval($config['import-account'] ?? 0);
|
||||
$importAccount = (int)($config['import-account'] ?? 0.0);
|
||||
$journal->asset->setDefaultAccountId($importAccount);
|
||||
|
||||
return $journal;
|
||||
|
||||
@@ -45,7 +45,7 @@ class AssetAccountIbans implements MapperInterface
|
||||
/** @var Account $account */
|
||||
foreach ($set as $account) {
|
||||
$iban = $account->iban ?? '';
|
||||
$accountId = intval($account->id);
|
||||
$accountId = (int)$account->id;
|
||||
if (strlen($iban) > 0) {
|
||||
$topList[$accountId] = $account->iban . ' (' . $account->name . ')';
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class AssetAccounts implements MapperInterface
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($set as $account) {
|
||||
$accountId = intval($account->id);
|
||||
$accountId = (int)$account->id;
|
||||
$name = $account->name;
|
||||
$iban = $account->iban ?? '';
|
||||
if (strlen($iban) > 0) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class Bills implements MapperInterface
|
||||
|
||||
/** @var Bill $bill */
|
||||
foreach ($result as $bill) {
|
||||
$billId = intval($bill->id);
|
||||
$billId = (int)$bill->id;
|
||||
$list[$billId] = $bill->name . ' [' . $bill->match . ']';
|
||||
}
|
||||
asort($list);
|
||||
|
||||
@@ -42,7 +42,7 @@ class Budgets implements MapperInterface
|
||||
|
||||
/** @var Budget $budget */
|
||||
foreach ($result as $budget) {
|
||||
$budgetId = intval($budget->id);
|
||||
$budgetId = (int)$budget->id;
|
||||
$list[$budgetId] = $budget->name;
|
||||
}
|
||||
asort($list);
|
||||
|
||||
@@ -42,7 +42,7 @@ class Categories implements MapperInterface
|
||||
|
||||
/** @var Category $category */
|
||||
foreach ($result as $category) {
|
||||
$categoryId = intval($category->id);
|
||||
$categoryId = (int)$category->id;
|
||||
$list[$categoryId] = $category->name;
|
||||
}
|
||||
asort($list);
|
||||
|
||||
@@ -51,7 +51,7 @@ class OpposingAccountIbans implements MapperInterface
|
||||
/** @var Account $account */
|
||||
foreach ($set as $account) {
|
||||
$iban = $account->iban ?? '';
|
||||
$accountId = intval($account->id);
|
||||
$accountId = (int)$account->id;
|
||||
if (strlen($iban) > 0) {
|
||||
$topList[$accountId] = $account->iban . ' (' . $account->name . ')';
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class OpposingAccounts implements MapperInterface
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($set as $account) {
|
||||
$accountId = intval($account->id);
|
||||
$accountId = (int)$account->id;
|
||||
$name = $account->name;
|
||||
$iban = $account->iban ?? '';
|
||||
if (strlen($iban) > 0) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class Tags implements MapperInterface
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($result as $tag) {
|
||||
$tagId = intval($tag->id);
|
||||
$tagId = (int)$tag->id;
|
||||
$list[$tagId] = $tag->tag;
|
||||
}
|
||||
asort($list);
|
||||
|
||||
@@ -39,7 +39,7 @@ class TransactionCurrencies implements MapperInterface
|
||||
$currencies = $repository->get();
|
||||
$list = [];
|
||||
foreach ($currencies as $currency) {
|
||||
$currencyId = intval($currency->id);
|
||||
$currencyId = (int)$currency->id;
|
||||
$list[$currencyId] = $currency->name . ' (' . $currency->code . ')';
|
||||
}
|
||||
asort($list);
|
||||
|
||||
@@ -34,11 +34,10 @@ class TagsComma implements PreProcessorInterface
|
||||
*/
|
||||
public function run(string $value): array
|
||||
{
|
||||
$set = explode(',', $value);
|
||||
$set = array_map('trim', $set);
|
||||
$set = array_filter($set, 'strlen');
|
||||
$return = array_values($set);
|
||||
$set = explode(',', $value);
|
||||
$set = array_map('trim', $set);
|
||||
$set = array_filter($set, 'strlen');
|
||||
|
||||
return $return;
|
||||
return array_values($set);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,10 @@ class TagsSpace implements PreProcessorInterface
|
||||
*/
|
||||
public function run(string $value): array
|
||||
{
|
||||
$set = explode(' ', $value);
|
||||
$set = array_map('trim', $set);
|
||||
$set = array_filter($set, 'strlen');
|
||||
$return = array_values($set);
|
||||
$set = explode(' ', $value);
|
||||
$set = array_map('trim', $set);
|
||||
$set = array_filter($set, 'strlen');
|
||||
|
||||
return $return;
|
||||
return array_values($set);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class ImportAccount
|
||||
/** @var int */
|
||||
private $defaultAccountId = 0;
|
||||
/** @var string */
|
||||
private $expectedType = '';
|
||||
private $expectedType;
|
||||
/**
|
||||
* This value is used to indicate the other account ID (the opposing transaction's account),
|
||||
* if it is know. If so, this particular import account may never return an Account with this ID.
|
||||
@@ -299,19 +299,19 @@ class ImportAccount
|
||||
/** @var AccountType $accountType */
|
||||
$accountType = $this->repository->getAccountType($this->expectedType);
|
||||
$result = $this->findById($accountType);
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = $this->findByIBAN($accountType);
|
||||
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = $this->findByName($accountType);
|
||||
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ class ImportAccount
|
||||
|
||||
Log::debug('Finding a mapped account based on', $array);
|
||||
|
||||
$search = intval($array['mapped'] ?? 0);
|
||||
$search = (int)($array['mapped'] ?? 0.0);
|
||||
$account = $this->repository->findNull($search);
|
||||
|
||||
if (null === $account) {
|
||||
@@ -401,10 +401,10 @@ class ImportAccount
|
||||
*/
|
||||
private function store(): bool
|
||||
{
|
||||
if (is_null($this->user)) {
|
||||
if (null === $this->user) {
|
||||
throw new FireflyException('ImportAccount cannot continue without user.');
|
||||
}
|
||||
if ((is_null($this->defaultAccountId) || 0 === intval($this->defaultAccountId)) && AccountType::ASSET === $this->expectedType) {
|
||||
if ((null === $this->defaultAccountId || 0 === (int)$this->defaultAccountId) && AccountType::ASSET === $this->expectedType) {
|
||||
throw new FireflyException('ImportAccount cannot continue without a default account to fall back on.');
|
||||
}
|
||||
// 1: find mapped object:
|
||||
|
||||
@@ -108,7 +108,7 @@ class ImportBill
|
||||
if (3 === count($this->id)) {
|
||||
Log::debug(sprintf('Finding bill with ID #%d', $this->id['value']));
|
||||
/** @var Bill $bill */
|
||||
$bill = $this->repository->find(intval($this->id['value']));
|
||||
$bill = $this->repository->find((int)$this->id['value']);
|
||||
if (null !== $bill) {
|
||||
Log::debug(sprintf('Found unmapped bill by ID (#%d): %s', $bill->id, $bill->name));
|
||||
|
||||
@@ -157,11 +157,11 @@ class ImportBill
|
||||
{
|
||||
Log::debug('In findExistingObject() for Bill');
|
||||
$result = $this->findById();
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
$result = $this->findByName();
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ class ImportBill
|
||||
|
||||
Log::debug('Finding a mapped bill based on', $array);
|
||||
|
||||
$search = intval($array['mapped']);
|
||||
$search = (int)$array['mapped'];
|
||||
$bill = $this->repository->find($search);
|
||||
|
||||
if (null === $bill) {
|
||||
|
||||
@@ -97,7 +97,7 @@ class ImportBudget
|
||||
if (3 === count($this->id)) {
|
||||
Log::debug(sprintf('Finding budget with ID #%d', $this->id['value']));
|
||||
/** @var Budget $budget */
|
||||
$budget = $this->repository->findNull(intval($this->id['value']));
|
||||
$budget = $this->repository->findNull((int)$this->id['value']);
|
||||
if (null !== $budget) {
|
||||
Log::debug(sprintf('Found unmapped budget by ID (#%d): %s', $budget->id, $budget->name));
|
||||
|
||||
@@ -146,11 +146,11 @@ class ImportBudget
|
||||
{
|
||||
Log::debug('In findExistingObject() for Budget');
|
||||
$result = $this->findById();
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
$result = $this->findByName();
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class ImportBudget
|
||||
|
||||
Log::debug('Finding a mapped budget based on', $array);
|
||||
|
||||
$search = intval($array['mapped']);
|
||||
$search = (int)$array['mapped'];
|
||||
$budget = $this->repository->find($search);
|
||||
|
||||
if (null === $budget->id) {
|
||||
|
||||
@@ -99,7 +99,7 @@ class ImportCategory
|
||||
if (3 === count($this->id)) {
|
||||
Log::debug(sprintf('Finding category with ID #%d', $this->id['value']));
|
||||
/** @var Category $category */
|
||||
$category = $this->repository->findNull(intval($this->id['value']));
|
||||
$category = $this->repository->findNull((int)$this->id['value']);
|
||||
if (null !== $category) {
|
||||
Log::debug(sprintf('Found unmapped category by ID (#%d): %s', $category->id, $category->name));
|
||||
|
||||
@@ -150,12 +150,12 @@ class ImportCategory
|
||||
{
|
||||
Log::debug('In findExistingObject() for Category');
|
||||
$result = $this->findById();
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = $this->findByName();
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ class ImportCategory
|
||||
|
||||
Log::debug('Finding a mapped category based on', $array);
|
||||
|
||||
$search = intval($array['mapped']);
|
||||
$search = (int)$array['mapped'];
|
||||
$category = $this->repository->findNull($search);
|
||||
|
||||
if (null === $category) {
|
||||
|
||||
@@ -114,7 +114,7 @@ class ImportCurrency
|
||||
*/
|
||||
public function setId(array $id)
|
||||
{
|
||||
$id['value'] = intval($id['value']);
|
||||
$id['value'] = (int)$id['value'];
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ class ImportCurrency
|
||||
|
||||
Log::debug('Finding a mapped object based on', $array);
|
||||
|
||||
$search = intval($array['mapped']);
|
||||
$search = (int)$array['mapped'];
|
||||
$currency = $this->repository->findNull($search);
|
||||
|
||||
if (null === $currency) {
|
||||
|
||||
@@ -71,7 +71,7 @@ class ImportJournal
|
||||
/** @var array */
|
||||
private $amountDebit;
|
||||
/** @var string */
|
||||
private $convertedAmount = null;
|
||||
private $convertedAmount;
|
||||
/** @var string */
|
||||
private $date = '';
|
||||
/** @var string */
|
||||
@@ -225,7 +225,7 @@ class ImportJournal
|
||||
public function getMetaString(string $field): ?string
|
||||
{
|
||||
if (isset($this->metaFields[$field]) && strlen($this->metaFields[$field]) > 0) {
|
||||
return strval($this->metaFields[$field]);
|
||||
return (string)$this->metaFields[$field];
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -277,7 +277,7 @@ class ImportJournal
|
||||
case 'sepa-country':
|
||||
case 'sepa-ep':
|
||||
case 'sepa-ci':
|
||||
$value = trim(strval($array['value']));
|
||||
$value = trim((string)$array['value']);
|
||||
if (strlen($value) > 0) {
|
||||
$this->metaFields[$array['role']] = $value;
|
||||
}
|
||||
@@ -448,17 +448,17 @@ class ImportJournal
|
||||
{
|
||||
$info = [];
|
||||
$converterClass = '';
|
||||
if (!is_null($this->amount)) {
|
||||
if (null !== $this->amount) {
|
||||
Log::debug('Amount value is not NULL, assume this is the correct value.');
|
||||
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amount['role'])));
|
||||
$info = $this->amount;
|
||||
}
|
||||
if (!is_null($this->amountDebit)) {
|
||||
if (null !== $this->amountDebit) {
|
||||
Log::debug('Amount DEBIT value is not NULL, assume this is the correct value (overrules Amount).');
|
||||
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amountDebit['role'])));
|
||||
$info = $this->amountDebit;
|
||||
}
|
||||
if (!is_null($this->amountCredit)) {
|
||||
if (null !== $this->amountCredit) {
|
||||
Log::debug('Amount CREDIT value is not NULL, assume this is the correct value (overrules Amount and AmountDebit).');
|
||||
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amountCredit['role'])));
|
||||
$info = $this->amountCredit;
|
||||
|
||||
@@ -58,7 +58,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
||||
Log::debug('Now in BunqPrerequisites::getViewParameters()');
|
||||
$apiKey = Preferences::getForUser($this->user, 'bunq_api_key', null);
|
||||
$string = '';
|
||||
if (!is_null($apiKey)) {
|
||||
if (null !== $apiKey) {
|
||||
$string = $apiKey->data;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
|
||||
public function getViewParameters(): array
|
||||
{
|
||||
$publicKey = $this->getPublicKey();
|
||||
$subTitle = strval(trans('import.spectre_title'));
|
||||
$subTitle = (string)trans('import.spectre_title');
|
||||
$subTitleIcon = 'fa-archive';
|
||||
|
||||
return compact('publicKey', 'subTitle', 'subTitleIcon');
|
||||
|
||||
@@ -325,7 +325,7 @@ class BunqRoutine implements RoutineInterface
|
||||
Log::debug('in convertToAccount()');
|
||||
// find opposing party by IBAN first.
|
||||
$result = $this->accountRepository->findByIbanNull($party->getIban(), [$expectedType]);
|
||||
if (!is_null($result)) {
|
||||
if (null !== $result) {
|
||||
Log::debug(sprintf('Search for %s resulted in account %s (#%d)', $party->getIban(), $result->name, $result->id));
|
||||
|
||||
return $result;
|
||||
@@ -334,7 +334,7 @@ class BunqRoutine implements RoutineInterface
|
||||
// try to find asset account just in case:
|
||||
if ($expectedType !== AccountType::ASSET) {
|
||||
$result = $this->accountRepository->findByIbanNull($party->getIban(), [AccountType::ASSET]);
|
||||
if (!is_null($result)) {
|
||||
if (nul !== $result) {
|
||||
Log::debug(sprintf('Search for Asset "%s" resulted in account %s (#%d)', $party->getIban(), $result->name, $result->id));
|
||||
|
||||
return $result;
|
||||
@@ -400,8 +400,6 @@ class BunqRoutine implements RoutineInterface
|
||||
Preferences::setForUser($this->job->user, 'bunq_private_key', $privKey);
|
||||
Preferences::setForUser($this->job->user, 'bunq_public_key', $pubKey['key']);
|
||||
Log::debug('Created and stored key pair');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -570,7 +568,7 @@ class BunqRoutine implements RoutineInterface
|
||||
private function getServerPublicKey(): ServerPublicKey
|
||||
{
|
||||
$pref = Preferences::getForUser($this->job->user, 'bunq_server_public_key', null)->data;
|
||||
if (is_null($pref)) {
|
||||
if (null === $pref) {
|
||||
throw new FireflyException('Cannot determine bunq server public key, but should have it at this point.');
|
||||
}
|
||||
|
||||
@@ -721,8 +719,6 @@ class BunqRoutine implements RoutineInterface
|
||||
// set status to "finished"?
|
||||
// update job:
|
||||
$this->setStatus('finished');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -778,7 +774,7 @@ class BunqRoutine implements RoutineInterface
|
||||
// we really have to quit at this point :(
|
||||
throw new FireflyException($e->getMessage());
|
||||
}
|
||||
if (is_null($deviceServerId)) {
|
||||
if (null === $deviceServerId) {
|
||||
throw new FireflyException('Was not able to register server with bunq. Please see the log files.');
|
||||
}
|
||||
|
||||
@@ -881,8 +877,6 @@ class BunqRoutine implements RoutineInterface
|
||||
// update job, set status to "configuring".
|
||||
$this->setStatus('configuring');
|
||||
$this->addStep();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -893,8 +887,6 @@ class BunqRoutine implements RoutineInterface
|
||||
private function setConfig(array $config): void
|
||||
{
|
||||
$this->repository->setConfiguration($this->job, $config);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -905,8 +897,6 @@ class BunqRoutine implements RoutineInterface
|
||||
private function setExtendedStatus(array $extended): void
|
||||
{
|
||||
$this->repository->setExtendedStatus($this->job, $extended);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,13 +24,13 @@ namespace FireflyIII\Import\Routine;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\Object\ImportJournal;
|
||||
use FireflyIII\Import\Storage\ImportStorage;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Services\Spectre\Exception\DuplicatedCustomerException;
|
||||
use FireflyIII\Services\Spectre\Exception\SpectreException;
|
||||
use FireflyIII\Services\Spectre\Object\Account;
|
||||
use FireflyIII\Services\Spectre\Object\Customer;
|
||||
@@ -179,11 +179,11 @@ class SpectreRoutine implements RoutineInterface
|
||||
try {
|
||||
$newCustomerRequest->call();
|
||||
$customer = $newCustomerRequest->getCustomer();
|
||||
} catch (DuplicatedCustomerException $e) {
|
||||
} catch (Exception $e) {
|
||||
// already exists, must fetch customer instead.
|
||||
Log::warning('Customer exists already for user, fetch it.');
|
||||
Log::warning(sprintf('Customer exists already for user, fetch it: %s', $e->getMessage()));
|
||||
}
|
||||
if (is_null($customer)) {
|
||||
if (null === $customer) {
|
||||
$getCustomerRequest = new ListCustomersRequest($this->job->user);
|
||||
$getCustomerRequest->call();
|
||||
$customers = $getCustomerRequest->getCustomers();
|
||||
@@ -211,7 +211,7 @@ class SpectreRoutine implements RoutineInterface
|
||||
protected function getCustomer(): Customer
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
if (!is_null($config['customer'])) {
|
||||
if (null !== $config['customer']) {
|
||||
$customer = new Customer($config['customer']);
|
||||
|
||||
return $customer;
|
||||
@@ -306,13 +306,13 @@ class SpectreRoutine implements RoutineInterface
|
||||
/** @var Login $login */
|
||||
foreach ($logins as $login) {
|
||||
$attempt = $login->getLastAttempt();
|
||||
$attemptTime = intval($attempt->getCreatedAt()->format('U'));
|
||||
if ($attemptTime > $time && is_null($attempt->getFailErrorClass())) {
|
||||
$attemptTime = (int)$attempt->getCreatedAt()->format('U');
|
||||
if ($attemptTime > $time && null === $attempt->getFailErrorClass()) {
|
||||
$time = $attemptTime;
|
||||
$final = $login;
|
||||
}
|
||||
}
|
||||
if (is_null($final)) {
|
||||
if (null === $final) {
|
||||
Log::error('Could not find a valid login for this user.');
|
||||
$this->repository->addError($this->job, 0, 'Spectre connection failed. Did you use invalid credentials, press Cancel or failed the 2FA challenge?');
|
||||
$this->repository->setStatus($this->job, 'error');
|
||||
@@ -420,8 +420,8 @@ class SpectreRoutine implements RoutineInterface
|
||||
}
|
||||
$extra = $transaction->getExtra()->toArray();
|
||||
$notes = '';
|
||||
$notes .= strval(trans('import.imported_from_account', ['account' => $account->getName()])) . ' '
|
||||
. "\n"; // double space for newline in Markdown.
|
||||
// double space for newline in Markdown.
|
||||
$notes .= (string)trans('import.imported_from_account', ['account' => $account->getName()]) . ' ' . "\n";
|
||||
|
||||
foreach ($extra as $key => $value) {
|
||||
switch ($key) {
|
||||
@@ -535,8 +535,8 @@ class SpectreRoutine implements RoutineInterface
|
||||
/** @var array $accountArray */
|
||||
foreach ($accounts as $accountArray) {
|
||||
$account = new Account($accountArray);
|
||||
$importId = intval($config['accounts-mapped'][$account->getId()] ?? 0);
|
||||
$doImport = 0 !== $importId ? true : false;
|
||||
$importId = (int)($config['accounts-mapped'][$account->getId()] ?? 0.0);
|
||||
$doImport = 0 !== $importId;
|
||||
if (!$doImport) {
|
||||
Log::debug(sprintf('Will NOT import from Spectre account #%d ("%s")', $account->getId(), $account->getName()));
|
||||
continue;
|
||||
|
||||
@@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\Storage;
|
||||
|
||||
use ErrorException;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\TransactionJournalFactory;
|
||||
@@ -160,7 +159,7 @@ class ImportStorage
|
||||
try {
|
||||
$this->storeImportJournal($index, $importJournal);
|
||||
$this->addStep();
|
||||
} catch (FireflyException | ErrorException | Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->errors->push($e->getMessage());
|
||||
Log::error(sprintf('Cannot import row #%d because: %s', $index, $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
@@ -239,7 +238,7 @@ class ImportStorage
|
||||
'description' => $importJournal->getDescription(),
|
||||
'piggy_bank_id' => null,
|
||||
'piggy_bank_name' => null,
|
||||
'bill_id' => is_null($bill) ? null : $bill->id,
|
||||
'bill_id' => null === $bill ? null : $bill->id,
|
||||
'bill_name' => null,
|
||||
'tags' => $importJournal->tags,
|
||||
'interest_date' => $importJournal->getMetaDate('interest_date'),
|
||||
@@ -262,14 +261,14 @@ class ImportStorage
|
||||
[
|
||||
'description' => null,
|
||||
'amount' => $amount,
|
||||
'currency_id' => intval($currencyId),
|
||||
'currency_id' => (int)$currencyId,
|
||||
'currency_code' => null,
|
||||
'foreign_amount' => $foreignAmount,
|
||||
'foreign_currency_id' => $foreignCurrencyId,
|
||||
'foreign_currency_code' => null,
|
||||
'budget_id' => is_null($budget) ? null : $budget->id,
|
||||
'budget_id' => null === $budget ? null : $budget->id,
|
||||
'budget_name' => null,
|
||||
'category_id' => is_null($category) ? null : $category->id,
|
||||
'category_id' => null === $category ? null : $category->id,
|
||||
'category_name' => null,
|
||||
'source_id' => $source->id,
|
||||
'source_name' => null,
|
||||
|
||||
@@ -91,7 +91,7 @@ trait ImportSupport
|
||||
*/
|
||||
protected function matchBills(TransactionJournal $journal): bool
|
||||
{
|
||||
if (!is_null($journal->bill_id)) {
|
||||
if (null !== $journal->bill_id) {
|
||||
Log::debug('Journal is already linked to a bill, will not scan.');
|
||||
|
||||
return true;
|
||||
@@ -134,7 +134,7 @@ trait ImportSupport
|
||||
{
|
||||
// start with currency pref of account, if any:
|
||||
$account = $importJournal->asset->getAccount();
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currencyId = (int)$account->getMeta('currency_id');
|
||||
if ($currencyId > 0) {
|
||||
return $currencyId;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ trait ImportSupport
|
||||
{
|
||||
// use given currency by import journal.
|
||||
$currency = $importJournal->foreignCurrency->getTransactionCurrency();
|
||||
if (null !== $currency && intval($currency->id) !== intval($currencyId)) {
|
||||
if (null !== $currency && (int)$currency->id !== (int)$currencyId) {
|
||||
return $currency->id;
|
||||
}
|
||||
|
||||
@@ -206,9 +206,7 @@ trait ImportSupport
|
||||
// amount is positive, it's a deposit, opposing is an revenue:
|
||||
$account->setExpectedType(AccountType::REVENUE);
|
||||
|
||||
$databaseAccount = $account->getAccount();
|
||||
|
||||
return $databaseAccount;
|
||||
return $account->getAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,7 +278,6 @@ trait ImportSupport
|
||||
* is not already present.
|
||||
*
|
||||
* @return array
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function getTransfers(): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user