This commit is contained in:
codemasher
2020-11-22 11:19:44 +01:00
parent 9cabb83ad3
commit 51ca0964d4
3 changed files with 24 additions and 5 deletions
+6 -1
View File
@@ -212,6 +212,9 @@ class EccLevel{
$this->eccLevel = $eccLevel;
}
/**
* returns the ordinal value of the current ECC level
*/
public function getOrdinal():int{
return $this->eccLevel;
}
@@ -234,7 +237,6 @@ class EccLevel{
/**
* returns the format pattern for the given $eccLevel and $maskPattern
*
* @return int
* @throws \chillerlan\QRCode\QRCodeException
*/
public function getformatPattern(int $maskPattern):int{
@@ -246,6 +248,9 @@ class EccLevel{
return self::formatPattern[self::MODES[$this->eccLevel]][$maskPattern];
}
/**
* returns an array wit the max bit lengths for version 1-40 and the current ECC level
*/
public function getMaxBits():array{
return array_combine(
array_keys(self::MAX_BITS),
+4 -4
View File
@@ -59,10 +59,10 @@ class Mode{
* @var string[]
*/
public const DATA_INTERFACES = [
Mode::DATA_NUMBER => Number::class,
Mode::DATA_ALPHANUM => AlphaNum::class,
Mode::DATA_KANJI => Kanji::class,
Mode::DATA_BYTE => Byte::class,
self::DATA_NUMBER => Number::class,
self::DATA_ALPHANUM => AlphaNum::class,
self::DATA_KANJI => Kanji::class,
self::DATA_BYTE => Byte::class,
];
/**
+14
View File
@@ -132,18 +132,32 @@ class Version{
$this->version = $version;
}
/**
* returns the current version number
*/
public function getVersionNumber():int{
return $this->version;
}
/**
* the matrix size for the given version
*/
public function getDimension():int{
return $this->version * 4 + 17;
}
/**
* the version pattern for the given version
*/
public function getVersionPattern():?int{
return self::VERSION_PATTERN[$this->version] ?? null;
}
/**
* the alignment patterns for the current version
*
* @return int[]
*/
public function getAlignmentPattern():array{
return self::ALIGNMENT_PATTERN[$this->version];
}