Skip to content

Barcode

Raxos\Wallet\Apple\Component\Barcode is a barcode entry attached to a Pass, combining a format, a message and optional alt text.

php
final readonly class Barcode implements ComponentInterface

Implements Raxos\Contract\Wallet\ComponentInterface (see raxos/contract).

Constructor

ParameterTypeDescription
formatBarcodeFormatThe barcode symbology.
messagestringThe encoded payload.
altTextstring|nullHuman readable text shown under the barcode.
messageEncodingstringEncoding of the message, defaults to iso-8859-1.

BarcodeFormat

The Raxos\Wallet\Apple\Enum\BarcodeFormat backed enum has four cases, each mapping to an Apple PassKit constant:

CaseValue
AZTECPKBarcodeFormatAztec
CODE128PKBarcodeFormatCode128
PDF417PKBarcodeFormatPDF417
QRPKBarcodeFormatQR

Methods

jsonSerialize(): array

Returns the barcode data, filtering out null and empty values.

Example

php
<?php
declare(strict_types=1);

use Raxos\Wallet\Apple\Component\Barcode;
use Raxos\Wallet\Apple\Enum\BarcodeFormat;

$barcode = new Barcode(
    format: BarcodeFormat::PDF417,
    message: 'TCK-00042',
    altText: 'TCK-00042'
);

See also