Skip to content

Commit 3dcea02

Browse files
authored
[MagicNumber] Use constant to store the default QR size
1 parent 3d5592f commit 3dcea02

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

QRCode.class.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
* @desc Compatible to vCard 4.0 or higher.
55
*
66
* @author Pierre-Henry Soria <ph7software@gmail.com>
7-
* @copyright (c) 2012-2018, Pierre-Henry Soria. All Rights Reserved.
7+
* @copyright (c) 2012-2021, Pierre-Henry Soria. All Rights Reserved.
88
* @license GNU General Public License <http://www.gnu.org/licenses/gpl.html>
99
* @version 1.2
1010
*/
1111

1212
class QRCode
1313
{
1414
const API_URL = 'https://chart.googleapis.com/chart?chs=';
15+
const DEFAULT_QR_SIZE = 150;
1516

1617
private $sData;
1718

@@ -273,7 +274,7 @@ public function bookmark($sTitle, $sUrl)
273274
*
274275
* @param string $sLat Latitude
275276
* @param string $sLon Longitude
276-
* @param integer $iHeight Height
277+
* @param int $iHeight Height
277278
*
278279
* @return self
279280
*/
@@ -324,24 +325,24 @@ public function finish()
324325
/**
325326
* Get the URL of QR Code.
326327
*
327-
* @param integer $iSize Default 150
328+
* @param int $iSize Default 150
328329
* @param string $sECLevel Default L
329330
* @param integer $iMargin Default 1
330331
*
331332
* @return string The API URL configure.
332333
*/
333-
public function get($iSize = 150, $sECLevel = 'L', $iMargin = 1)
334+
public function get($iSize = self::DEFAULT_QR_SIZE, $sECLevel = 'L', $iMargin = 1)
334335
{
335336
return self::API_URL . $iSize . 'x' . $iSize . '&cht=qr&chld=' . $sECLevel . '|' . $iMargin . '&chl=' . $this->sData;
336337
}
337338

338339
/**
339340
* The HTML code for displaying the QR Code.
340341
*
341-
* @param integer $iSize Default 150
342+
* @param int $iSize Default 150
342343
* @return void
343344
*/
344-
public function display( $iSize = 150)
345+
public function display($iSize = self::DEFAULT_QR_SIZE)
345346
{
346347
echo '<p class="center"><img src="' . $this->_cleanUrl($this->get($iSize)) . '" alt="QR Code" /></p>';
347348
}

0 commit comments

Comments
 (0)