CommandScheduler::getCommands()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace JMS\JobQueueBundle\Cron;
4
5
use JMS\JobQueueBundle\Console\CronCommand;
6
use JMS\JobQueueBundle\Entity\Job;
7
8
class CommandScheduler implements JobScheduler
9
{
10
    private $name;
11
    private $command;
12
13 2
    public function __construct(string $name, CronCommand $command)
14
    {
15 2
        $this->name = $name;
16 2
        $this->command = $command;
17 2
    }
18
19
    public function getCommands(): array
20
    {
21
        return [$this->name];
22
    }
23
24 2
    public function shouldSchedule(string $_, \DateTime $lastRunAt): bool
25
    {
26 2
        return $this->command->shouldBeScheduled($lastRunAt);
27
    }
28
29 2
    public function createJob(string $_, \DateTime $lastRunAt): Job
30
    {
31 2
        return $this->command->createCronJob($lastRunAt);
32
    }
33
}