Skip to content

Commit

Permalink
CronAbstract 基类
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanyanwow committed Nov 27, 2019
1 parent aa1b2a7 commit 643c93a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/siam/AbstractInterface/CronAbstract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* 任务模板基类 定义格式
* User: Siam
* Date: 2019/11/27
* Time: 9:12
*/

namespace Siam\AbstractInterface;


abstract class CronAbstract
{
public function __construct()
{
set_time_limit(0);
}

/**
* 写明监控时间周期
* @return mixed
*/
abstract function rule();

/**
* 执行逻辑
* @return mixed
*/
public function run(){
$data = $this->before();

$res = $this->doJob($data);

return $this->after($res);
}

/**
* @return mixed
*/
abstract function before();

/**
* @param null $data
* @return bool
*/
abstract function doJob($data = NULL);

/**
* @param bool $res
* @return mixed
*/
abstract function after($res = true);

protected function log($string)
{
echo date('Y-m-d H:i:s')." {$string} ". PHP_EOL;
}
}

0 comments on commit 643c93a

Please sign in to comment.