Expression::getNextRun()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace BrainExe\Core\Cron;
4
5
use BrainExe\Core\Annotations\Service;
6
use Cron\CronExpression;
7
8
/**
9
 * @Service
10
 */
11
class Expression
12
{
13
14
    /**
15
     * @param string $expression
16
     * @param string $currentTime
17
     * @return int
18
     */
19 3
    public function getNextRun(string $expression, $currentTime = 'now') : int
20
    {
21 3
        $cron = CronExpression::factory($expression);
22
23 3
        return $cron->getNextRunDate($currentTime)->getTimestamp();
24
    }
25
}
26