1 | <?php |
||
2 | |||
3 | namespace Dongdavid\Notify; |
||
4 | |||
5 | use Dongdavid\Notify\utils\Http; |
||
6 | |||
7 | /** |
||
8 | * 消息发送类. |
||
9 | */ |
||
10 | abstract class Sender |
||
11 | { |
||
12 | protected $config = []; |
||
13 | |||
14 | abstract public function send($data); |
||
15 | |||
16 | abstract public function checkConfig(); |
||
17 | |||
18 | abstract public function checkMsgFormate($msg); |
||
19 | |||
20 | public function setConfig($config) |
||
21 | { |
||
22 | $this->config = $config; |
||
23 | // 检查配置是否完整 |
||
24 | $this->checkConfig(); |
||
25 | |||
26 | return $this; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * 从数据库获取配置. |
||
31 | * |
||
32 | * @param $tag 配置标识 |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
33 | */ |
||
34 | // protected function getConfigByDatabase($signature) |
||
35 | // { |
||
36 | // if (!is_string($signature)) { |
||
37 | // throw new \Exception("请传入config tag"); |
||
38 | // } |
||
39 | // if (!$config) { |
||
40 | // throw new \Exception("无效的config signature"); |
||
41 | // } |
||
42 | |||
43 | // $this->config = $config; |
||
44 | // } |
||
45 | public function post($url, $data) |
||
46 | { |
||
47 | return Http::post($url, $data); |
||
48 | } |
||
49 | } |
||
50 |