oliverdavies.uk/modules/Experience/TwigExtension/ExperienceTwigExtension.php
2024-08-04 12:39:48 +01:00

30 lines
668 B
PHP

<?php
namespace Modules\Experience\TwigExtension;
use Sculpin\Contrib\ProxySourceCollection\ProxySourceItem;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class ExperienceTwigExtension extends AbstractExtension
{
private static $startYear = 2007;
public function getFunctions(): array
{
return [
new TwigFunction('get_years_of_experience', [$this, 'getYearsOfExperience']),
];
}
public function getName(): string
{
return 'modules.experience';
}
public function getYearsOfExperience(): int
{
return (new \DateTimeImmutable())->format('Y') - self::$startYear;
}
}