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

SchedulerFacade::getQueuedJobs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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