for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Class QRDataAbstract
*
* @filesource QRDataAbstract.php
* @created 25.11.2015
* @package chillerlan\QRCode\Data
* @author Smiley <[email protected]>
* @copyright 2015 Smiley
* @license MIT
*/
namespace chillerlan\QRCode\Data;
abstract class QRDataAbstract implements QRDataInterface{
* @var string
public $data;
* @var int
public $dataLength;
* @var array
protected $lengthBits = [0, 0, 0];
* QRDataAbstract constructor.
* @param string $data
public function __construct($data){
$this->data = $data;
$this->dataLength = strlen($data);
}
* @param int $type
* @return int
* @throws \chillerlan\QRCode\Data\QRCodeDataException
* @see QRCode::createData()
* @codeCoverageIgnore
public function getLengthInBits($type){
switch(true){
case $type >= 1 && $type <= 9:
return $this->lengthBits[0]; // 1 - 9
case $type <= 26:
return $this->lengthBits[1]; // 10 - 26
case $type <= 40:
return $this->lengthBits[2]; // 27 - 40
default:
throw new QRCodeDataException('$type: '.$type);