Skip to content

Commit 643c93a

Browse files
committed
CronAbstract 基类
1 parent aa1b2a7 commit 643c93a

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* 任务模板基类 定义格式
4+
* User: Siam
5+
* Date: 2019/11/27
6+
* Time: 9:12
7+
*/
8+
9+
namespace Siam\AbstractInterface;
10+
11+
12+
abstract class CronAbstract
13+
{
14+
public function __construct()
15+
{
16+
set_time_limit(0);
17+
}
18+
19+
/**
20+
* 写明监控时间周期
21+
* @return mixed
22+
*/
23+
abstract function rule();
24+
25+
/**
26+
* 执行逻辑
27+
* @return mixed
28+
*/
29+
public function run(){
30+
$data = $this->before();
31+
32+
$res = $this->doJob($data);
33+
34+
return $this->after($res);
35+
}
36+
37+
/**
38+
* @return mixed
39+
*/
40+
abstract function before();
41+
42+
/**
43+
* @param null $data
44+
* @return bool
45+
*/
46+
abstract function doJob($data = NULL);
47+
48+
/**
49+
* @param bool $res
50+
* @return mixed
51+
*/
52+
abstract function after($res = true);
53+
54+
protected function log($string)
55+
{
56+
echo date('Y-m-d H:i:s')." {$string} ". PHP_EOL;
57+
}
58+
}

0 commit comments

Comments
 (0)