:octocat: remove unnecessary Mode::getLengthBitsForMode()

This commit is contained in:
smiley
2023-03-13 15:17:24 +01:00
parent 9977c51180
commit 9eba4ada08
3 changed files with 1 additions and 22 deletions
-14
View File
@@ -92,18 +92,4 @@ final class Mode{
throw new QRCodeException(sprintf('invalid version number: %d', $version));
}
/**
* returns the array of length bits for the given mode
*
* @throws \chillerlan\QRCode\QRCodeException
*/
public static function getLengthBitsForMode(int $mode):array{
if(isset(self::LENGTH_BITS[$mode])){
return self::LENGTH_BITS[$mode];
}
throw new QRCodeException('invalid mode given');
}
}
+1 -1
View File
@@ -140,7 +140,7 @@ final class QRData{
foreach($this->dataSegments as $segment){
// data length in bits of the current segment +4 bits for each mode descriptor
$length += ($segment->getLengthInBits() + Mode::getLengthBitsForMode($segment->getDataMode())[0] + 4);
$length += ($segment->getLengthInBits() + Mode::getLengthBitsForVersion($segment->getDataMode(), 1) + 4);
if(!$segment instanceof ECI){
// mode length bits margin to the next breakpoint
-7
View File
@@ -54,11 +54,4 @@ final class ModeTest extends TestCase{
Mode::getLengthBitsForVersion(Mode::BYTE, 69);
}
public function testGetLengthBitsForModeInvalidModeException():void{
$this->expectException(QRCodeException::class);
$this->expectExceptionMessage('invalid mode given');
/** @phan-suppress-next-line PhanNoopNew */
Mode::getLengthBitsForMode(42);
}
}