public static function terminal($text, $level = Constants::QR_ECLEVEL_L, $size = 3, $margin = 4) { $backColor = "[40m [0m"; $foreColor = "[47m [0m"; $enc = QRencode::factory($level, $size, $margin); $qrcode = $enc->encode($text, false); $output = ''; foreach ($qrcode as $k => $qr) { $len = strlen($qr); $border = str_repeat($foreColor, $len + 2); if ($k === 0) { $output .= $border . "\n"; } $curLine = ''; for ($i = 0; $i < strlen($qr); $i++) { $curLine .= $qr[$i] ? $backColor : $foreColor; } $output .= $foreColor . $curLine . $foreColor . "\n"; if ($k === $len - 1) { $output .= $border . "\n"; } } return $output; }
public static function raw($text, $outfile = false, $level = Constants::QR_ECLEVEL_L, $size = 3, $margin = 4) { $enc = QRencode::factory($level, $size, $margin); return $enc->encodeRAW($text, $outfile); }