mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup
This commit is contained in:
@@ -102,7 +102,7 @@ class Initial implements ConfigurationInterface
|
||||
Log::debug('Now in storeConfiguration for file Upload.');
|
||||
$config = $this->getConfig();
|
||||
$type = $data['import_file_type'] ?? 'csv'; // assume it's a CSV file.
|
||||
$config['file-type'] = in_array($type, config('import.options.file.import_formats')) ? $type : 'csv';
|
||||
$config['file-type'] = \in_array($type, config('import.options.file.import_formats'), true) ? $type : 'csv';
|
||||
|
||||
// update config:
|
||||
$this->repository->setConfiguration($this->job, $config);
|
||||
@@ -118,7 +118,7 @@ class Initial implements ConfigurationInterface
|
||||
}
|
||||
|
||||
if (false === $uploaded) {
|
||||
$this->warning = 'No valid upload.';
|
||||
$this->warning = (string)trans('firefly.upload_error');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -159,12 +159,12 @@ class Map implements ConfigurationInterface
|
||||
$config = $this->getConfig();
|
||||
|
||||
if (isset($data['mapping'])) {
|
||||
foreach ($data['mapping'] as $index => $data) {
|
||||
foreach ($data['mapping'] as $index => $array) {
|
||||
$config['column-mapping-config'][$index] = [];
|
||||
foreach ($data as $value => $mapId) {
|
||||
$mapId = intval($mapId);
|
||||
foreach ($array as $value => $mapId) {
|
||||
$mapId = (int)$mapId;
|
||||
if (0 !== $mapId) {
|
||||
$config['column-mapping-config'][$index][$value] = intval($mapId);
|
||||
$config['column-mapping-config'][$index][$value] = $mapId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,10 +186,8 @@ class Map implements ConfigurationInterface
|
||||
{
|
||||
$mapperClass = config('csv.import_roles.' . $column . '.mapper');
|
||||
$mapperName = sprintf('\\FireflyIII\\Import\Mapper\\%s', $mapperClass);
|
||||
/** @var MapperInterface $mapper */
|
||||
$mapper = app($mapperName);
|
||||
|
||||
return $mapper;
|
||||
return app($mapperName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -73,7 +73,7 @@ class Roles implements ConfigurationInterface
|
||||
}
|
||||
|
||||
// example rows:
|
||||
$stmt = (new Statement)->limit(intval(config('csv.example_rows', 5)))->offset($offset);
|
||||
$stmt = (new Statement)->limit((int)config('csv.example_rows', 5))->offset($offset);
|
||||
// set data:
|
||||
$roles = $this->getRoles();
|
||||
asort($roles);
|
||||
@@ -274,14 +274,14 @@ class Roles implements ConfigurationInterface
|
||||
}
|
||||
// warn if has foreign amount but no currency code:
|
||||
if ($hasForeignAmount && !$hasForeignCode) {
|
||||
$this->warning = strval(trans('import.foreign_amount_warning'));
|
||||
$this->warning = (string)trans('import.foreign_amount_warning');
|
||||
Log::debug('isRolesComplete() returns FALSE because foreign amount present without foreign code.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 === $assigned || !$hasAmount) {
|
||||
$this->warning = strval(trans('import.roles_warning'));
|
||||
$this->warning = (string)trans('import.roles_warning');
|
||||
Log::debug('isRolesComplete() returns FALSE because no amount present.');
|
||||
|
||||
return false;
|
||||
|
@@ -114,16 +114,16 @@ class UploadConfig implements ConfigurationInterface
|
||||
{
|
||||
Log::debug('Now in Initial::storeConfiguration()');
|
||||
$config = $this->getConfig();
|
||||
$importId = intval($data['csv_import_account'] ?? 0);
|
||||
$importId = (int)($data['csv_import_account'] ?? 0.0);
|
||||
$account = $this->accountRepository->find($importId);
|
||||
$delimiter = strval($data['csv_delimiter']);
|
||||
$delimiter = (string)$data['csv_delimiter'];
|
||||
|
||||
// set "headers":
|
||||
$config['has-headers'] = intval($data['has_headers'] ?? 0) === 1;
|
||||
$config['date-format'] = strval($data['date_format']);
|
||||
$config['has-headers'] = (int)($data['has_headers'] ?? 0.0) === 1;
|
||||
$config['date-format'] = (string)$data['date_format'];
|
||||
$config['delimiter'] = 'tab' === $delimiter ? "\t" : $delimiter;
|
||||
$config['apply-rules'] = intval($data['apply_rules'] ?? 0) === 1;
|
||||
$config['match-bills'] = intval($data['match_bills'] ?? 0) === 1;
|
||||
$config['apply-rules'] = (int)($data['apply_rules'] ?? 0.0) === 1;
|
||||
$config['match-bills'] = (int)($data['match_bills'] ?? 0.0) === 1;
|
||||
|
||||
Log::debug('Entered import account.', ['id' => $importId]);
|
||||
|
||||
|
Reference in New Issue
Block a user