mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 03:14:32 +02:00
Applied rector with PHP8.1 migration rules
This commit is contained in:
parent
dc6a67c2f0
commit
7ee01d9a05
303 changed files with 1228 additions and 3465 deletions
|
@ -50,12 +50,8 @@ use InvalidArgumentException;
|
|||
|
||||
final class BarcodeGenerator
|
||||
{
|
||||
private BarcodeContentGenerator $barcodeContentGenerator;
|
||||
|
||||
|
||||
public function __construct(BarcodeContentGenerator $barcodeContentGenerator)
|
||||
public function __construct(private readonly BarcodeContentGenerator $barcodeContentGenerator)
|
||||
{
|
||||
$this->barcodeContentGenerator = $barcodeContentGenerator;
|
||||
}
|
||||
|
||||
public function generateHTMLBarcode(LabelOptions $options, object $target): ?string
|
||||
|
@ -126,18 +122,11 @@ final class BarcodeGenerator
|
|||
|
||||
public function getContent(LabelOptions $options, AbstractDBElement $target): ?string
|
||||
{
|
||||
switch ($options->getBarcodeType()) {
|
||||
case 'qr':
|
||||
case 'datamatrix':
|
||||
return $this->barcodeContentGenerator->getURLContent($target);
|
||||
case 'code39':
|
||||
case 'code93':
|
||||
case 'code128':
|
||||
return $this->barcodeContentGenerator->get1DBarcodeContent($target);
|
||||
case 'none':
|
||||
return null;
|
||||
default:
|
||||
throw new InvalidArgumentException('Unknown label type!');
|
||||
}
|
||||
return match ($options->getBarcodeType()) {
|
||||
'qr', 'datamatrix' => $this->barcodeContentGenerator->getURLContent($target),
|
||||
'code39', 'code93', 'code128' => $this->barcodeContentGenerator->get1DBarcodeContent($target),
|
||||
'none' => null,
|
||||
default => throw new InvalidArgumentException('Unknown label type!'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue