CommandScheduler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 1
dl 0
loc 26
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCommands() 0 4 1
A shouldSchedule() 0 4 1
A createJob() 0 4 1
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
}