You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Malio/app/Utils/QRcode.php

28 lines
585 B
PHTML

9 years ago
<?php
declare(strict_types=1);
9 years ago
namespace App\Utils;
use Zxing\QrReader;
9 years ago
class QRcode
{
/**
* Decode QR code
*
* @param string $source QR code source url/path
*
* @return string|null Decoded string, null for empty
*/
public static function decode(string $source)
9 years ago
{
$img = file_get_contents($source);
$qrcode = new QrReader($img, QrReader::SOURCE_TYPE_BLOB);
$text = $qrcode->text();
if ($text == false || $text == '') {
9 years ago
return null;
}
return $text;
}
}