1 | <?php |
||
12 | class QRCode |
||
13 | { |
||
14 | const API_URL = 'https://chart.googleapis.com/chart?chs='; |
||
15 | |||
16 | private $sData; |
||
17 | |||
18 | /** |
||
19 | * Constructor. |
||
20 | */ |
||
21 | public function __construct() |
||
26 | |||
27 | /** |
||
28 | * The name of the person. |
||
29 | * |
||
30 | * @param string $sName |
||
31 | * |
||
32 | * @return self |
||
33 | */ |
||
34 | public function name($sName) |
||
39 | |||
40 | /** |
||
41 | * The full name of the person. |
||
42 | * |
||
43 | * @param string $sFullName |
||
44 | * |
||
45 | * @return self this |
||
46 | */ |
||
47 | public function fullName($sFullName) |
||
52 | |||
53 | /** |
||
54 | * @param string $sAddress |
||
55 | * |
||
56 | * @return self |
||
57 | */ |
||
58 | public function address($sAddress) |
||
64 | |||
65 | /** |
||
66 | * @param string $sNickname |
||
67 | * |
||
68 | * @return self |
||
69 | */ |
||
70 | public function nickName($sNickname) |
||
75 | |||
76 | /** |
||
77 | * @param string $sMail |
||
78 | * |
||
79 | * @return self |
||
80 | */ |
||
81 | public function email($sMail) |
||
86 | |||
87 | /** |
||
88 | * @param string $sVal |
||
89 | * |
||
90 | * @return self |
||
91 | */ |
||
92 | public function workPhone($sVal) |
||
97 | |||
98 | /** |
||
99 | * @param string $sVal |
||
100 | * |
||
101 | * @return self |
||
102 | */ |
||
103 | public function homePhone($sVal) |
||
108 | |||
109 | /** |
||
110 | * @param string $sUrl |
||
111 | * |
||
112 | * @return self |
||
113 | */ |
||
114 | public function url($sUrl) |
||
120 | |||
121 | /** |
||
122 | * @param string $sPhone |
||
123 | * @param string $sText |
||
124 | * |
||
125 | * @return self |
||
126 | */ |
||
127 | public function sms($sPhone, $sText) |
||
132 | |||
133 | /** |
||
134 | * @param string $sBirthday Date in the format YYYY-MM-DD or ISO 8601 |
||
135 | * |
||
136 | * @return self |
||
137 | */ |
||
138 | public function birthday($sBirthday) |
||
143 | |||
144 | /** |
||
145 | * @param string $sBirthDate Date in the format YYYY-MM-DD or ISO 8601 |
||
146 | * |
||
147 | * @return self |
||
148 | */ |
||
149 | public function anniversary($sBirthDate) |
||
154 | |||
155 | /** |
||
156 | * @param string $sSex F = Female. M = Male |
||
157 | * |
||
158 | * @return self |
||
159 | */ |
||
160 | public function gender($sSex) |
||
165 | |||
166 | /** |
||
167 | * A list of "tags" that can be used to describe the object represented by this vCard. |
||
168 | * |
||
169 | * @param string $sCategories |
||
170 | * |
||
171 | * @return self |
||
172 | */ |
||
173 | public function categories($sCategories) |
||
178 | |||
179 | /** |
||
180 | * The instant messenger (Instant Messaging and Presence Protocol). |
||
181 | * |
||
182 | * @param string $sVal |
||
183 | * |
||
184 | * @return self |
||
185 | */ |
||
186 | public function impp($sVal) |
||
191 | |||
192 | /** |
||
193 | * Photo (avatar). |
||
194 | * |
||
195 | * @param string $sImgUrl URL of the image. |
||
196 | * |
||
197 | * @return self |
||
198 | * |
||
199 | * @throws InvalidArgumentException If the image format is invalid. |
||
200 | */ |
||
201 | public function photo($sImgUrl) |
||
215 | |||
216 | /** |
||
217 | * The role, occupation, or business category of the vCard object within an organization. |
||
218 | * |
||
219 | * @param string $sRole e.g., Executive |
||
220 | * |
||
221 | * @return self |
||
222 | */ |
||
223 | public function role($sRole) |
||
228 | |||
229 | /** |
||
230 | * The organization / company. |
||
231 | * |
||
232 | * The name and optionally the unit(s) of the organization |
||
233 | * associated with the vCard object. This property is based on the X.520 Organization Name |
||
234 | * attribute and the X.520 Organization Unit attribute. |
||
235 | * |
||
236 | * @param string $sOrg e.g., Google;GMail Team;Spam Detection Squad |
||
237 | * |
||
238 | * @return self |
||
239 | */ |
||
240 | public function organization($sOrg) |
||
245 | |||
246 | /** |
||
247 | * The supplemental information or a comment that is associated with the vCard. |
||
248 | * |
||
249 | * @param string $sText |
||
250 | * |
||
251 | * @return self |
||
252 | */ |
||
253 | public function note($sText) |
||
258 | |||
259 | /** |
||
260 | * @param string $sTitle |
||
261 | * @param string $sUrl |
||
262 | * |
||
263 | * @return self |
||
264 | */ |
||
265 | public function bookmark($sTitle, $sUrl) |
||
270 | |||
271 | /** |
||
272 | * Geo location. |
||
273 | * |
||
274 | * @param string $sLat Latitude |
||
275 | * @param string $sLon Longitude |
||
276 | * @param integer $iHeight Height |
||
277 | * |
||
278 | * @return self |
||
279 | */ |
||
280 | public function geo($sLat, $sLon, $iHeight) |
||
285 | |||
286 | /** |
||
287 | * The language that the person speaks. |
||
288 | * |
||
289 | * @param string $sLang e.g., en-US |
||
290 | * |
||
291 | * @return self |
||
292 | */ |
||
293 | public function lang($sLang) |
||
298 | |||
299 | /** |
||
300 | * @param string $sType |
||
301 | * @param string $sSsid |
||
302 | * @param string $sPwd |
||
303 | * |
||
304 | * @return self |
||
305 | */ |
||
306 | public function wifi($sType, $sSsid, $sPwd) |
||
311 | |||
312 | /** |
||
313 | * Generate the QR code. |
||
314 | * |
||
315 | * @return self |
||
316 | */ |
||
317 | public function finish() |
||
323 | |||
324 | /** |
||
325 | * Get the URL of QR Code. |
||
326 | * |
||
327 | * @param integer $iSize Default 150 |
||
328 | * @param string $sECLevel Default L |
||
329 | * @param integer $iMargin Default 1 |
||
330 | * |
||
331 | * @return string The API URL configure. |
||
332 | */ |
||
333 | public function get($iSize = 150, $sECLevel = 'L', $iMargin = 1) |
||
337 | |||
338 | /** |
||
339 | * The HTML code for displaying the QR Code. |
||
340 | * |
||
341 | * @return void |
||
342 | */ |
||
343 | public function display() |
||
347 | |||
348 | /** |
||
349 | * Clean URL. |
||
350 | * |
||
351 | * @param string $sUrl |
||
352 | * |
||
353 | * @return string |
||
354 | */ |
||
355 | private function _cleanUrl($sUrl) |
||
359 | } |
||
360 |