mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-05 21:53:41 +00:00
Various code cleanup.
This commit is contained in:
@@ -205,7 +205,7 @@ class ImportableConverter
|
||||
$transactionType = $this->getTransactionType($source->accountType->type, $destination->accountType->type);
|
||||
$currency = $currency ?? $this->getCurrency($source, $destination);
|
||||
|
||||
if ($transactionType === 'unknown') {
|
||||
if ('unknown' === $transactionType) {
|
||||
$message = sprintf(
|
||||
'Cannot determine transaction type. Source account is a %s, destination is a %s', $source->accountType->type, $destination->accountType->type
|
||||
);
|
||||
@@ -282,14 +282,14 @@ class ImportableConverter
|
||||
if ($destination->accountType->type === AccountType::ASSET) {
|
||||
// destination is asset, might have currency preference:
|
||||
$destinationCurrencyId = (int)$this->accountRepository->getMetaValue($destination, 'currency_id');
|
||||
$currency = $destinationCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($destinationCurrencyId, []);
|
||||
$currency = 0 === $destinationCurrencyId ? $this->defaultCurrency : $this->currencyMapper->map($destinationCurrencyId, []);
|
||||
Log::debug(sprintf('Destination is an asset account, and has currency preference %s', $currency->code));
|
||||
}
|
||||
|
||||
if ($source->accountType->type === AccountType::ASSET) {
|
||||
// source is asset, might have currency preference:
|
||||
$sourceCurrencyId = (int)$this->accountRepository->getMetaValue($source, 'currency_id');
|
||||
$currency = $sourceCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($sourceCurrencyId, []);
|
||||
$currency = 0 === $sourceCurrencyId ? $this->defaultCurrency : $this->currencyMapper->map($sourceCurrencyId, []);
|
||||
Log::debug(sprintf('Source is an asset account, and has currency preference %s', $currency->code));
|
||||
}
|
||||
if (null === $currency) {
|
||||
|
||||
@@ -123,7 +123,7 @@ class LineReader
|
||||
/** @var array $config */
|
||||
$config = $this->importJob->configuration;
|
||||
Log::debug('now in getLines()');
|
||||
$offset = isset($config['has-headers']) && $config['has-headers'] === true ? 1 : 0;
|
||||
$offset = isset($config['has-headers']) && true === $config['has-headers'] ? 1 : 0;
|
||||
try {
|
||||
$stmt = (new Statement)->offset($offset);
|
||||
// @codeCoverageIgnoreStart
|
||||
@@ -151,7 +151,7 @@ class LineReader
|
||||
$collection = $this->repository->getAttachments($this->importJob);
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($collection as $attachment) {
|
||||
if ($attachment->filename === 'import_file') {
|
||||
if ('import_file' === $attachment->filename) {
|
||||
$content = $this->attachments->getAttachmentContent($attachment);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ class MappingConverger
|
||||
$value = trim($value);
|
||||
$originalRole = $this->roles[$columnIndex] ?? '_ignore';
|
||||
Log::debug(sprintf('Now at column #%d (%s), value "%s"', $columnIndex, $originalRole, $value));
|
||||
if ($originalRole !== '_ignore' && \strlen($value) > 0) {
|
||||
if ('_ignore' !== $originalRole && \strlen($value) > 0) {
|
||||
|
||||
// is a mapped value present?
|
||||
$mapped = $this->mapping[$columnIndex][$value] ?? 0;
|
||||
|
||||
@@ -53,7 +53,7 @@ class OpposingAccountMapper
|
||||
$expectedType = AccountType::EXPENSE;
|
||||
$result = null;
|
||||
Log::debug(sprintf('Going to search for accounts of type %s', $expectedType));
|
||||
if (bccomp($amount, '0') === 1) {
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
// more than zero.
|
||||
$expectedType = AccountType::REVENUE;
|
||||
Log::debug(sprintf('Because amount is %s, will instead search for accounts of type %s', $amount, $expectedType));
|
||||
|
||||
Reference in New Issue
Block a user