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 | 30 | public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = null, $limit = 160) |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | * |
||
78 | * @param array $record |
||
79 | * @return string |
||
80 | */ |
||
81 | 24 | protected function generateDataStream($record) |
|
86 | |||
87 | /** |
||
88 | * Builds the body of API call |
||
89 | * |
||
90 | * @param array $record |
||
91 | * @return string |
||
92 | */ |
||
93 | abstract protected function buildContent($record); |
||
94 | |||
95 | /** |
||
96 | * Builds the URL for the API call |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | abstract protected function buildRequestUrl(); |
||
101 | |||
102 | /** |
||
103 | * Builds the header of the API call |
||
104 | * |
||
105 | * @param string $content |
||
106 | * @return string |
||
107 | */ |
||
108 | 24 | private function buildHeader($content) |
|
121 | |||
122 | |||
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | * |
||
127 | * @param array $record |
||
128 | */ |
||
129 | 24 | protected function write(array $record) |
|
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | 6 | protected function getDefaultFormatter() |
|
142 | } |
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: