CronExpressionExtension::getNextRunDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusSchedulerPlugin\Twig;
6
7
use Cron\CronExpression;
8
9
class CronExpressionExtension extends \Twig_Extension
10
{
11
    /**
12
     * @return array
13
     */
14
    public function getFilters(): array
15
    {
16
        return [
17
            new \Twig_SimpleFilter('next_run_date', [$this, 'getNextRunDate']),
18
        ];
19
    }
20
21
    /**
22
     * @param string $cronExpression
23
     *
24
     * @return \DateTime
25
     */
26
    public function getNextRunDate(string $cronExpression): \DateTime
27
    {
28
        return CronExpression::factory($cronExpression)->getNextRunDate();
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getName(): string
35
    {
36
        return 'setono_cron_expression';
37
    }
38
}
39