2015-07-05 08:16:44 -05:00
|
|
|
<?php
|
2016-02-05 05:08:25 -06:00
|
|
|
declare(strict_types = 1);
|
2015-07-05 08:16:44 -05:00
|
|
|
namespace FireflyIII\Helpers\Csv\Converter;
|
|
|
|
|
|
|
|
use FireflyIII\Models\TransactionCurrency;
|
2016-04-01 07:10:08 -05:00
|
|
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
2015-07-05 08:16:44 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class CurrencyId
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Helpers\Csv\Converter
|
|
|
|
*/
|
|
|
|
class CurrencyId extends BasicConverter implements ConverterInterface
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2016-01-19 01:48:38 -06:00
|
|
|
* @return TransactionCurrency
|
2015-07-05 08:16:44 -05:00
|
|
|
*/
|
2016-04-06 09:37:28 -05:00
|
|
|
public function convert(): TransactionCurrency
|
2015-07-05 08:16:44 -05:00
|
|
|
{
|
2016-04-01 07:10:08 -05:00
|
|
|
/** @var CurrencyRepositoryInterface $repository */
|
|
|
|
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
2016-04-26 23:43:17 -05:00
|
|
|
$value = isset($this->mapped[$this->index][$this->value]) ? $this->mapped[$this->index][$this->value] : $this->value;
|
|
|
|
$currency = $repository->find($value);
|
2015-07-05 08:16:44 -05:00
|
|
|
|
|
|
|
return $currency;
|
|
|
|
}
|
2015-07-09 14:26:40 -05:00
|
|
|
}
|