| Total Complexity | 5 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class SchedulerFactory |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var \Jellyfish\Process\ProcessFacadeInterface |
||
| 12 | */ |
||
| 13 | protected $processFacade; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var \Jellyfish\Scheduler\SchedulerInterface |
||
| 17 | */ |
||
| 18 | protected $scheduler; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param \Jellyfish\Process\ProcessFacadeInterface $processFacade |
||
| 22 | */ |
||
| 23 | public function __construct(ProcessFacadeInterface $processFacade) |
||
| 24 | { |
||
| 25 | $this->processFacade = $processFacade; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $expression |
||
| 30 | * |
||
| 31 | * @return \Cron\CronExpression |
||
| 32 | */ |
||
| 33 | protected function createCronExpression(string $expression): CronExpression |
||
| 34 | { |
||
| 35 | return CronExpression::factory($expression); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param string[] $command |
||
| 40 | * @param string $cronExpression |
||
| 41 | * |
||
| 42 | * @return \Jellyfish\Scheduler\JobInterface |
||
| 43 | */ |
||
| 44 | public function createJob(array $command, string $cronExpression): JobInterface |
||
| 45 | { |
||
| 46 | return new Job( |
||
| 47 | $this->processFacade->createProcess($command), |
||
| 48 | $this->createCronExpression($cronExpression) |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return \Jellyfish\Scheduler\SchedulerInterface |
||
| 54 | */ |
||
| 55 | public function getScheduler(): SchedulerInterface |
||
| 62 | } |
||
| 63 | } |
||
| 64 |