mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-09-06 23:49:02 +00:00
use sprintf instead of concatenating
This commit is contained in:
@@ -23,11 +23,12 @@ class GoogleChartsQrCodeProvider extends BaseHTTPQRCodeProvider
|
||||
|
||||
public function getUrl(string $qrtext, int $size): string
|
||||
{
|
||||
return 'https://chart.googleapis.com/chart'
|
||||
. '?chs=' . $size . 'x' . $size
|
||||
. '&chld=' . urlencode(strtoupper($this->errorcorrectionlevel) . '|' . $this->margin)
|
||||
. '&cht=' . 'qr'
|
||||
. '&choe=' . $this->encoding
|
||||
. '&chl=' . rawurlencode($qrtext);
|
||||
return sprintf(
|
||||
'https://chart.googleapis.com/chart?chs=%1$sx%1$s&chld=%2$s&cht=qr&choe=%3$s&chl=%4$s',
|
||||
$size,
|
||||
urlencode(strtoupper($this->errorcorrectionlevel) . '|' . $this->margin),
|
||||
$this->encoding,
|
||||
rawurlencode($qrtext)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,12 @@ class ImageChartsQRCodeProvider extends BaseHTTPQRCodeProvider
|
||||
|
||||
public function getUrl(string $qrtext, int $size): string
|
||||
{
|
||||
return 'https://image-charts.com/chart?cht=qr'
|
||||
. '&chs=' . ceil($size / 2) . 'x' . ceil($size / 2)
|
||||
. '&chld=' . $this->errorcorrectionlevel . '|' . $this->margin
|
||||
. '&chl=' . rawurlencode($qrtext);
|
||||
return sprintf(
|
||||
'https://image-charts.com/chart?cht=qr&chs=%1$dx%1$d&chld=%2$s|%3$s&chl=%4$s',
|
||||
ceil($size / 2),
|
||||
$this->errorcorrectionlevel,
|
||||
$this->margin,
|
||||
rawurlencode($qrtext)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,17 @@ class QRServerProvider extends BaseHTTPQRCodeProvider
|
||||
|
||||
public function getUrl(string $qrtext, int $size): string
|
||||
{
|
||||
return 'https://api.qrserver.com/v1/create-qr-code/'
|
||||
. '?size=' . $size . 'x' . $size
|
||||
. '&ecc=' . strtoupper($this->errorcorrectionlevel)
|
||||
. '&margin=' . $this->margin
|
||||
. '&qzone=' . $this->qzone
|
||||
. '&bgcolor=' . $this->decodeColor($this->bgcolor)
|
||||
. '&color=' . $this->decodeColor($this->color)
|
||||
. '&format=' . strtolower($this->format)
|
||||
. '&data=' . rawurlencode($qrtext);
|
||||
return sprintf(
|
||||
'https://api.qrserver.com/v1/create-qr-code/?size=%1$sx%1$s&ecc=%2$s&margin=%3$s&qzone=%4$s&bgcolor=%5$s&color=%6$s&format=%7$s&data=%8$s',
|
||||
$size,
|
||||
strtoupper($this->errorcorrectionlevel),
|
||||
$this->margin,
|
||||
$this->qzone,
|
||||
$this->decodeColor($this->bgcolor),
|
||||
$this->decodeColor($this->color),
|
||||
strtolower($this->format),
|
||||
rawurlencode($qrtext)
|
||||
);
|
||||
}
|
||||
|
||||
private function decodeColor(string $value): string
|
||||
|
||||
@@ -34,12 +34,14 @@ class QRicketProvider extends BaseHTTPQRCodeProvider
|
||||
|
||||
public function getUrl(string $qrtext, int $size): string
|
||||
{
|
||||
return 'http://qrickit.com/api/qr'
|
||||
. '?qrsize=' . $size
|
||||
. '&e=' . strtolower($this->errorcorrectionlevel)
|
||||
. '&bgdcolor=' . $this->bgcolor
|
||||
. '&fgdcolor=' . $this->color
|
||||
. '&t=' . strtolower($this->format)
|
||||
. '&d=' . rawurlencode($qrtext);
|
||||
return sprintf(
|
||||
'http://qrickit.com/api/qr?qrsize=%s&e=%s&bgdcolor=%s&fgdcolor=%s&t=%s&d=%s',
|
||||
$size,
|
||||
strtolower($this->errorcorrectionlevel),
|
||||
$this->bgcolor,
|
||||
$this->color,
|
||||
strtolower($this->format),
|
||||
rawurlencode($qrtext)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user