forked from vmari/CronBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCronService.php
More file actions
46 lines (39 loc) · 880 Bytes
/
CronService.php
File metadata and controls
46 lines (39 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* This file is part of Cron Bundle.
*
* @category bundle
*
* @author Pedro Pelaez <aaaaa976@gmail.com>
*
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GPL v2
*
* @link https://github.com/vmari/CronBundle
*/
namespace VM\Cron;
use Exception;
/**
* Cron helper service.
*/
class CronService
{
/**
* Validate cron job class.
*
* @param string $class Job class name.
*
* @return bool
*
* @throws Exception
*/
public static function validateCronJobClass($class)
{
if (class_exists($class, true)) {
if (isset(class_implements($class, true)['VM\Cron\JobInterface'])) {
return true;
}
throw new Exception('Worker must implement JobInterface');
}
throw new Exception('Worker class not found');
}
}