1 | <?php |
||
10 | abstract class SMSHandler extends SocketHandler |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $authToken; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $authId; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $fromNumber; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $toNumber; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $host; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $version; |
||
42 | |||
43 | /** |
||
44 | * @param string $authToken Plivo API Auth Token |
||
45 | * @param string $authId Plivo API Auth ID |
||
46 | * @param string $fromNumber The phone number that will be shown as the sender ID |
||
47 | * @param string $toNumber The phone number to which the message will be sent |
||
48 | * @param int $level The minimum logging level at which this handler will be triggered |
||
49 | * @param bool $bubble Whether the messages that are handled can bubble up the stack or not |
||
50 | * @param bool $useSSL Whether to connect via SSL. |
||
51 | * @param string $host The Plivo server hostname. |
||
52 | * @param string $version The Plivo API version (default PlivoHandler::API_V1) |
||
53 | * @param string $limit The character limit |
||
54 | */ |
||
55 | 45 | public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = null, $limit = 160) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | * |
||
76 | * @param array $record |
||
77 | * @return string |
||
78 | */ |
||
79 | 36 | protected function generateDataStream($record) |
|
84 | |||
85 | /** |
||
86 | * Builds the body of API call |
||
87 | * |
||
88 | * @param array $record |
||
89 | * @return string |
||
90 | */ |
||
91 | abstract protected function buildContent($record); |
||
92 | |||
93 | /** |
||
94 | * Builds the URL for the API call |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | abstract protected function buildRequestUrl(); |
||
99 | |||
100 | /** |
||
101 | * Builds the header of the API call |
||
102 | * |
||
103 | * @param string $content |
||
104 | * @return string |
||
105 | */ |
||
106 | 36 | private function buildHeader($content) |
|
123 | |||
124 | |||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | * |
||
129 | * @param array $record |
||
130 | */ |
||
131 | 36 | protected function write(array $record) |
|
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | 9 | protected function getDefaultFormatter() |
|
144 | } |
||
145 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: