Each CSV converter can set the certainty of their conversion.

This commit is contained in:
James Cole 2016-07-29 21:29:46 +02:00
parent e434de72a3
commit 7707c81b2d
2 changed files with 16 additions and 0 deletions

View File

@ -34,6 +34,8 @@ class AccountId extends BasicConverter implements ConverterInterface
Log::debug('Going to convert using AssetAccountId', ['value' => $value]);
if ($value === 0) {
$this->setCertainty(0);
return new Account;
}
@ -47,6 +49,8 @@ class AccountId extends BasicConverter implements ConverterInterface
if (!is_null($account->id)) {
Log::debug('Found account by ID', ['id' => $account->id]);
$this->setCertainty(100);
return $account;
}
}
@ -54,11 +58,15 @@ class AccountId extends BasicConverter implements ConverterInterface
// not mapped? Still try to find it first:
$account = $repository->find($value);
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?
return new Account;

View File

@ -40,6 +40,14 @@ class BasicConverter
return $this->certainty;
}
/**
* @param int $certainty
*/
protected function setCertainty(int $certainty)
{
$this->certainty = $certainty;
}
/**
* @param array $config
*/