typeIcon()];
return $filters;
}
/**
* @return array
*/
public function getFunctions(): array
{
$functions = [
$this->invalidJournal(),
];
return $functions;
}
/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName(): string
{
return 'FireflyIII\Support\Twig\Journals';
}
/**
* @return Twig_SimpleFunction
*/
protected function invalidJournal(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'invalidJournal', function (TransactionJournal $journal): bool {
if (!isset($journal->transactions[1]) || !isset($journal->transactions[0])) {
return true;
}
return false;
}
);
}
/**
* @return Twig_SimpleFilter
*/
protected function typeIcon(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'typeIcon', function (TransactionJournal $journal): string {
$cache = new CacheProperties();
$cache->addProperty($journal->id);
$cache->addProperty('typeIcon');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
switch (true) {
case $journal->isWithdrawal():
$txt = '';
break;
case $journal->isDeposit():
$txt = '';
break;
case $journal->isTransfer():
$txt = '';
break;
case $journal->isOpeningBalance():
$txt = '';
break;
default:
$txt = '';
break;
}
$cache->store($txt);
return $txt;
}, ['is_safe' => ['html']]
);
}
}