mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
35 lines
900 B
PHP
35 lines
900 B
PHP
<?php
|
|
declare(strict_types = 1);
|
|
namespace FireflyIII\Helpers\Csv\Converter;
|
|
|
|
use FireflyIII\Models\Account;
|
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
|
|
/**
|
|
* Class OpposingAccountName
|
|
*
|
|
* @package FireflyIII\Helpers\Csv\Converter
|
|
*/
|
|
class OpposingAccountName extends BasicConverter implements ConverterInterface
|
|
{
|
|
|
|
/**
|
|
* If mapped, return account. Otherwise, only return the name itself.
|
|
*
|
|
* @return Account|string
|
|
*/
|
|
public function convert()
|
|
{
|
|
/** @var AccountRepositoryInterface $repository */
|
|
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
|
|
|
if (isset($this->mapped[$this->index][$this->value])) {
|
|
$account = $repository->find($this->mapped[$this->index][$this->value]);
|
|
|
|
return $account;
|
|
} else {
|
|
return $this->value;
|
|
}
|
|
}
|
|
}
|