<?php
namespace Veno\QrCdr\Lib;

/**
 * QR Code Reed-Solomon Block Class (Private Fork for Veno QrCdr)
 *
 * Container for data codewords and their calculated ECC codewords.
 *
 * @package   QrCdr
 * @version   1.1.4-patched
 */

if ( ! defined( 'ABSPATH' ) && ! defined( 'QRCDR_OPEN_ACCESS' ) ) {
	exit;
}

class QrcdrRsBlock {

	/**
	 * Number of data codewords.
	 * @var int
	 */
	public $dataLength;

	/**
	 * Data codewords array.
	 * @var array
	 */
	public $data = array();

	/**
	 * Number of ECC codewords.
	 * @var int
	 */
	public $eccLength;

	/**
	 * ECC codewords array.
	 * @var array
	 */
	public $ecc = array();

	/**
	 * Constructor.
	 *
	 * Initializes the block and calculates ECC using the provided RS codec.
	 *
	 * @param int      $data_length Length of data codewords.
	 * @param array    $data        Data codewords.
	 * @param int      $ecc_length  Length of ECC codewords.
	 * @param array    &$ecc        Reference array to populate with ECC.
	 * @param QrcdrRsItem $rs          The Reed-Solomon codec.
	 */
	public function __construct( $data_length, $data, $ecc_length, &$ecc, QrcdrRsItem $rs ) {
		$rs->encode_rs_char( $data, $ecc );
		$this->dataLength = $data_length;
		$this->data       = $data;
		$this->eccLength  = $ecc_length;
		$this->ecc        = $ecc;
	}
}
