mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
36 lines
940 B
PHP
36 lines
940 B
PHP
<?php
|
|
declare(strict_types = 1);
|
|
namespace FireflyIII\Helpers\Csv\Converter;
|
|
|
|
use FireflyIII\Models\Account;
|
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
|
|
/**
|
|
* Class AccountId
|
|
*
|
|
* @package FireflyIII\Helpers\Csv\Converter
|
|
*/
|
|
class AccountId extends BasicConverter implements ConverterInterface
|
|
{
|
|
|
|
/**
|
|
* @return Account
|
|
*/
|
|
public function convert(): Account
|
|
{
|
|
/** @var AccountRepositoryInterface $repository */
|
|
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
|
|
|
// is mapped? Then it's easy!
|
|
if (isset($this->mapped[$this->index][$this->value])) {
|
|
/** @var Account $account */
|
|
$account = $repository->find($this->mapped[$this->index][$this->value]);
|
|
} else {
|
|
/** @var Account $account */
|
|
$account = $repository->find($this->value);
|
|
}
|
|
|
|
return $account;
|
|
}
|
|
}
|