1<?php
2
3namespace Mpdf\QrCode\Output;
4
5use Mpdf\QrCode\QrCode;
6
7class Html
8{
9
10	/**
11	 * @param \Mpdf\QrCode\QrCode $qrCode
12	 *
13	 * @return string
14	 */
15	public function output(QrCode $qrCode)
16	{
17		$s = '';
18
19		$qrSize = $qrCode->getQrSize();
20		$final = $qrCode->getFinal();
21
22		if ($qrCode->isBorderDisabled()) {
23			$minSize = 4;
24			$maxSize = $qrSize - 4;
25		} else {
26			$minSize = 0;
27			$maxSize = $qrSize;
28		}
29
30		$s .= '<table class="qr" cellpadding="0" cellspacing="0" style="font-size: 1px;">' . "\n";
31
32		for ($y = $minSize; $y < $maxSize; $y++) {
33			$s .= '<tr style="height: 4px;">';
34			for ($x = $minSize; $x < $maxSize; $x++) {
35				$on = $final[$x + $y * $qrSize + 1];
36				$s .= '<td class="' . ($on ? 'on' : 'off') . '" style="width: 4px; background-color: ' . ($on ? '#000' : '#FFF') . '">&nbsp;</td>';
37			}
38			$s .= '</tr>' . "\n";
39		}
40
41		$s .= '</table>';
42
43		return $s;
44	}
45
46}
47