Skip to content

Commit 9eba4ad

Browse files
committed
:octocat: remove unnecessary Mode::getLengthBitsForMode()
1 parent 9977c51 commit 9eba4ad

File tree

3 files changed

+1
-22
lines changed

3 files changed

+1
-22
lines changed

src/Common/Mode.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,4 @@ public static function getLengthBitsForVersion(int $mode, int $version):int{
9292
throw new QRCodeException(sprintf('invalid version number: %d', $version));
9393
}
9494

95-
/**
96-
* returns the array of length bits for the given mode
97-
*
98-
* @throws \chillerlan\QRCode\QRCodeException
99-
*/
100-
public static function getLengthBitsForMode(int $mode):array{
101-
102-
if(isset(self::LENGTH_BITS[$mode])){
103-
return self::LENGTH_BITS[$mode];
104-
}
105-
106-
throw new QRCodeException('invalid mode given');
107-
}
108-
10995
}

src/Data/QRData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private function estimateTotalBitLength():int{
140140

141141
foreach($this->dataSegments as $segment){
142142
// data length in bits of the current segment +4 bits for each mode descriptor
143-
$length += ($segment->getLengthInBits() + Mode::getLengthBitsForMode($segment->getDataMode())[0] + 4);
143+
$length += ($segment->getLengthInBits() + Mode::getLengthBitsForVersion($segment->getDataMode(), 1) + 4);
144144

145145
if(!$segment instanceof ECI){
146146
// mode length bits margin to the next breakpoint

tests/Common/ModeTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,4 @@ public function testGetLengthBitsForVersionInvalidVersionException():void{
5454
Mode::getLengthBitsForVersion(Mode::BYTE, 69);
5555
}
5656

57-
public function testGetLengthBitsForModeInvalidModeException():void{
58-
$this->expectException(QRCodeException::class);
59-
$this->expectExceptionMessage('invalid mode given');
60-
/** @phan-suppress-next-line PhanNoopNew */
61-
Mode::getLengthBitsForMode(42);
62-
}
63-
6457
}

0 commit comments

Comments
 (0)