for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* BarcodeBox class.
*
* @package YetiForcePDF\Layout
* @copyright YetiForce Sp. z o.o
* @license MIT
* @author Rafal Pospiech <[email protected]>
*/
namespace YetiForcePDF\Layout;
use Milon\Barcode\DNS1D;
* Class BarcodeBox.
class BarcodeBox extends InlineBlockBox
{
* @var string barcode type
protected $type = 'EAN13';
* @var string barcode size
protected $size = '3';
* @var string barcode height
protected $height = '33';
* @var string code
protected $code = '';
* Get barcode type.
* @return string
public function getType(): string
return $this->type;
}
* Set barcode type.
* @param string $type
* @return $this
public function setType(string $type)
$this->type = $type;
return $this;
* Get barcode size.
public function getSize(): string
return $this->size;
* Set barcode size.
* @param string $size
public function setSize(string $size)
$this->size = $size;
* Get barcode height.
public function getHeight(): string
return $this->height;
* Set barcode height.
* @param string $height
public function setHeight(string $height)
$this->height = $height;
* Get code.
public function getCode(): string
return $this->code;
* Set code.
* @param string $code
public function setCode(string $code)
$this->code = $code;
* Generate barcode image.
public function generateBarcodeImage()
$barcode = new DNS1D();
$barcode->setStorPath(__DIR__ . '/cache/');
$image = 'data:image/png;base64,' . $barcode->getBarcodePNG($this->getCode(), $this->getType(), (int) $this->getSize(), (int) $this->getHeight());
$barcode->getBarcodePNG(...int)$this->getHeight())
false|string
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
$image = 'data:image/png;base64,' . /** @scrutinizer ignore-type */ $barcode->getBarcodePNG($this->getCode(), $this->getType(), (int) $this->getSize(), (int) $this->getHeight());
$this->getStyle()->setContent("background-image: url($image)");