Various code cleanup.

This commit is contained in:
James Cole
2018-07-27 05:03:37 +02:00
parent 0312ba8ad7
commit e3e0e12fef
43 changed files with 167 additions and 145 deletions

View File

@@ -98,7 +98,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
$config['account_mapping'] = $final;
$config['apply-rules'] = $applyRules;
$this->repository->setConfiguration($this->importJob, $config);
if ($final === [0 => 0] || \count($final) === 0) {
if ($final === [0 => 0] || 0 === \count($final)) {
$messages->add('count', (string)trans('import.spectre_no_mapping'));
}
@@ -116,7 +116,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
Log::debug('Now in ChooseAccountsHandler::getnextData()');
$config = $this->importJob->configuration;
$accounts = $config['accounts'] ?? [];
if (\count($accounts) === 0) {
if (0 === \count($accounts)) {
throw new FireflyException('It seems you have no accounts with this bank. The import cannot continue.'); // @codeCoverageIgnore
}
$converted = [];
@@ -128,15 +128,15 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
$login = null;
$logins = $config['all-logins'] ?? [];
$selected = $config['selected-login'] ?? 0;
if (\count($logins) === 0) {
if (0 === \count($logins)) {
throw new FireflyException('It seems you have no configured logins in this import job. The import cannot continue.'); // @codeCoverageIgnore
}
Log::debug(sprintf('Selected login to use is %d', $selected));
if ($selected === 0) {
if (0 === $selected) {
$login = new Login($logins[0]);
Log::debug(sprintf('Will use login %d (%s %s)', $login->getId(), $login->getProviderName(), $login->getCountryCode()));
}
if ($selected !== 0) {
if (0 !== $selected) {
foreach ($logins as $loginArray) {
$loginId = $loginArray['id'] ?? -1;
if ($loginId === $selected) {

View File

@@ -82,7 +82,7 @@ class ChooseLoginHandler implements SpectreJobConfigurationInterface
Log::debug(sprintf('The selected login by the user is #%d', $selectedLogin));
// if selected login is zero, create a new one.
if ($selectedLogin === 0) {
if (0 === $selectedLogin) {
Log::debug('Login is zero, get Spectre customer + token and store it in config.');
$customer = $this->getCustomer($this->importJob);
// get a token for the user and redirect to next stage