# woocommerce-pos/1.10.20/vendor_prefixed/chillerlan/php-qrcode/src/Data/Byte.php

WCPOS – Point of Sale (POS) plugin for WooCommerce, version 1.10.20. 75 lines.

- Page: https://pluginprobe.com/plugins/woocommerce-pos/1.10.20/code/vendor_prefixed/chillerlan/php-qrcode/src/Data/Byte.php
- Raw: https://pluginprobe.com/plugins/woocommerce-pos/1.10.20/raw/vendor_prefixed/chillerlan/php-qrcode/src/Data/Byte.php
- Modified: 2026-06-09T13:55:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woocommerce-pos/1.10.20/code/vendor_prefixed/chillerlan/php-qrcode/src/Data/Byte.php#L10-L20`.

```php
<?php

/**
 * Class Byte
 *
 * @created      25.11.2015
 * @author       Smiley <smiley@chillerlan.net>
 * @copyright    2015 Smiley
 * @license      MIT
 */
namespace WCPOS\Vendor\chillerlan\QRCode\Data;

use WCPOS\Vendor\chillerlan\QRCode\Common\BitBuffer;
use WCPOS\Vendor\chillerlan\QRCode\Common\Mode;
use function chr, ord;
/**
 * 8-bit Byte mode, ISO-8859-1 or UTF-8
 *
 * ISO/IEC 18004:2000 Section 8.3.4
 * ISO/IEC 18004:2000 Section 8.4.4
 */
final class Byte extends QRDataModeAbstract
{
    /**
     * @inheritDoc
     */
    public const DATAMODE = Mode::BYTE;
    /**
     * @inheritDoc
     */
    public function getLengthInBits() : int
    {
        return $this->getCharCount() * 8;
    }
    /**
     * @inheritDoc
     */
    public static function validateString(string $string) : bool
    {
        return $string !== '';
    }
    /**
     * @inheritDoc
     */
    public function write(BitBuffer $bitBuffer, int $versionNumber) : QRDataModeInterface
    {
        $len = $this->getCharCount();
        $bitBuffer->put(self::DATAMODE, 4)->put($len, $this::getLengthBits($versionNumber));
        $i = 0;
        while ($i < $len) {
            $bitBuffer->put(ord($this->data[$i]), 8);
            $i++;
        }
        return $this;
    }
    /**
     * @inheritDoc
     *
     * @throws \chillerlan\QRCode\Data\QRCodeDataException
     */
    public static function decodeSegment(BitBuffer $bitBuffer, int $versionNumber) : string
    {
        $length = $bitBuffer->read(self::getLengthBits($versionNumber));
        if ($bitBuffer->available() < 8 * $length) {
            throw new QRCodeDataException('not enough bits available');
            // @codeCoverageIgnore
        }
        $readBytes = '';
        for ($i = 0; $i < $length; $i++) {
            $readBytes .= chr($bitBuffer->read(8));
        }
        return $readBytes;
    }
}

```
