Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
FormatDateTwigExtension
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 formatDate
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Twig extension to format the date
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ\Template
11 * @author    Jan Harms <model_railroader@gmx-topmail.de>
12 * @copyright 2024-2026 phpMyFAQ Team
13 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14 * @link      https://www.phpmyfaq.de
15 * @since     2024-04-27
16 */
17
18declare(strict_types=1);
19
20namespace phpMyFAQ\Twig\Extensions;
21
22use phpMyFAQ\Configuration;
23use phpMyFAQ\Date;
24use Twig\Attribute\AsTwigFilter;
25use Twig\Extension\AbstractExtension;
26
27class FormatDateTwigExtension extends AbstractExtension
28{
29    #[AsTwigFilter(name: 'formatDate')]
30    public static function formatDate(string $string): string
31    {
32        $configuration = Configuration::getConfigurationInstance();
33        $date = new Date($configuration);
34        return $date->format($string);
35    }
36}