Optimised some code.

This commit is contained in:
James Cole
2016-07-30 16:29:04 +02:00
parent 1e724712e0
commit 541d9ebdd9
7 changed files with 862 additions and 665 deletions

View File

@@ -32,17 +32,13 @@ class AccountId extends BasicConverter implements ConverterInterface
{
$value = intval(trim($value));
Log::debug('Going to convert using AssetAccountId', ['value' => $value]);
if ($value === 0) {
$this->setCertainty(0);
return new Account;
}
/** @var AccountCrudInterface $repository */
$repository = app(AccountCrudInterface::class, [$this->user]);
if (isset($this->mapping[$value])) {
Log::debug('Found account in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);
$account = $repository->find(intval($this->mapping[$value]));
@@ -54,20 +50,15 @@ class AccountId extends BasicConverter implements ConverterInterface
return $account;
}
}
// not mapped? Still try to find it first:
$account = $repository->find($value);
$account = $repository->find($value);// not mapped? Still try to find it first:
if (!is_null($account->id)) {
$this->setCertainty(90);
Log::debug('Found account by ID ', ['id' => $account->id]);
return $account;
}
$this->setCertainty(0); // should not really happen. If the ID does not match FF, what is FF supposed to do?
$this->setCertainty(0);
// should not really happen. If the ID does not match FF, what is FF supposed to do?
return new Account;
}

View File

@@ -33,7 +33,7 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
$value = trim($value);
Log::debug('Going to convert using CurrencySymbol', ['value' => $value]);
if ($value === 0) {
if (strlen($value) === 0) {
$this->setCertainty(0);
return new TransactionCurrency;
}