12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- declare(strict_types = 1);
- namespace BaconQrCode\Common;
- use DASPRiD\Enum\AbstractEnum;
- final class Mode extends AbstractEnum
- {
- protected const TERMINATOR = [[0, 0, 0], 0x00];
- protected const NUMERIC = [[10, 12, 14], 0x01];
- protected const ALPHANUMERIC = [[9, 11, 13], 0x02];
- protected const STRUCTURED_APPEND = [[0, 0, 0], 0x03];
- protected const BYTE = [[8, 16, 16], 0x04];
- protected const ECI = [[0, 0, 0], 0x07];
- protected const KANJI = [[8, 10, 12], 0x08];
- protected const FNC1_FIRST_POSITION = [[0, 0, 0], 0x05];
- protected const FNC1_SECOND_POSITION = [[0, 0, 0], 0x09];
- protected const HANZI = [[8, 10, 12], 0x0d];
-
- private $characterCountBitsForVersions;
-
- private $bits;
- protected function __construct(array $characterCountBitsForVersions, int $bits)
- {
- $this->characterCountBitsForVersions = $characterCountBitsForVersions;
- $this->bits = $bits;
- }
-
- public function getCharacterCountBits(Version $version) : int
- {
- $number = $version->getVersionNumber();
- if ($number <= 9) {
- $offset = 0;
- } elseif ($number <= 26) {
- $offset = 1;
- } else {
- $offset = 2;
- }
- return $this->characterCountBitsForVersions[$offset];
- }
-
- public function getBits() : int
- {
- return $this->bits;
- }
- }
|