1 | <?php |
||
2 | |||
3 | namespace Jaby\Sms; |
||
4 | |||
5 | class SmsService |
||
6 | { |
||
7 | |||
8 | protected $driver ; |
||
9 | |||
10 | protected $mode ; |
||
11 | |||
12 | protected $class ; |
||
13 | |||
14 | |||
15 | /** |
||
16 | * SmsService constructor. |
||
17 | */ |
||
18 | public function __construct() |
||
19 | { |
||
20 | $this->driver = config('sms.default'); |
||
21 | |||
22 | $this->class = config('sms.map.'.$this->driver); |
||
23 | |||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param $key |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function driver($key) |
||
31 | { |
||
32 | $this->driver = $key ; |
||
33 | |||
34 | $this->class = config('sms.map.'.$this->driver); |
||
35 | |||
36 | return $this; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param $text |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function text($text) |
||
44 | { |
||
45 | $drive = $this->drive('text',[$text]); |
||
46 | |||
47 | return $drive; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param null $code |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
52 | * @return mixed |
||
53 | */ |
||
54 | public function pattern($code = null) |
||
55 | { |
||
56 | $drive = $this->drive('pattern',[$code]); |
||
57 | |||
58 | return $drive; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param $key |
||
63 | * @param array $params |
||
64 | * @return mixed |
||
65 | */ |
||
66 | public function drive($key,$params = []) |
||
67 | { |
||
68 | $class = new $this->class; |
||
69 | |||
70 | return call_user_func_array(array($class,$key),$params); |
||
71 | } |
||
72 | |||
73 | } |
||
74 |