Passed
Pull Request — master (#39)
by Daniel
02:27
created

SchedulerFacade   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 1
b 0
f 0
dl 0
loc 64
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A runScheduler() 0 5 1
A getQueuedJobs() 0 3 1
A createJob() 0 3 1
A clearJobs() 0 5 1
A __construct() 0 3 1
A queueJob() 0 5 1
1
<?php
2
3
namespace Jellyfish\Scheduler;
4
5
class SchedulerFacade implements SchedulerFacadeInterface
6
{
7
    /**
8
     * @var \Jellyfish\Scheduler\SchedulerFactory
9
     */
10
    protected $factory;
11
12
    /**
13
     * @param \Jellyfish\Scheduler\SchedulerFactory $factory
14
     */
15
    public function __construct(SchedulerFactory $factory)
16
    {
17
        $this->factory = $factory;
18
    }
19
20
    /**
21
     * @param string[] $command
22
     * @param string $cronExpression
23
     *
24
     * @return \Jellyfish\Scheduler\JobInterface
25
     */
26
    public function createJob(array $command, string $cronExpression): JobInterface
27
    {
28
        return $this->factory->createJob($command, $cronExpression);
29
    }
30
31
    /**
32
     * @param \Jellyfish\Scheduler\JobInterface $job
33
     *
34
     * @return SchedulerFacadeInterface
35
     */
36
    public function queueJob(JobInterface $job): SchedulerFacadeInterface
37
    {
38
        $this->factory->getScheduler()->queueJob($job);
39
40
        return $this;
41
    }
42
43
    /**
44
     * @return \Jellyfish\Scheduler\SchedulerFacadeInterface
45
     */
46
    public function runScheduler(): SchedulerFacadeInterface
47
    {
48
        $this->factory->getScheduler()->run();
49
50
        return $this;
51
    }
52
53
    /**
54
     * @return \Jellyfish\Scheduler\JobInterface[]
55
     */
56
    public function getQueuedJobs(): array
57
    {
58
        return $this->factory->getScheduler()->getQueuedJobs();
59
    }
60
61
    /**
62
     * @return \Jellyfish\Scheduler\SchedulerFacadeInterface
63
     */
64
    public function clearJobs(): SchedulerFacadeInterface
65
    {
66
        $this->factory->getScheduler()->clearJobs();
67
68
        return $this;
69
    }
70
}
71