Преглед изворни кода

:octocat: remove unnecessary Mode::getLengthBitsForMode()

smiley пре 2 година
родитељ
комит
9eba4ada08
3 измењених фајлова са 1 додато и 22 уклоњено
  1. 0 14
      src/Common/Mode.php
  2. 1 1
      src/Data/QRData.php
  3. 0 7
      tests/Common/ModeTest.php

+ 0 - 14
src/Common/Mode.php

@@ -92,18 +92,4 @@ final class Mode{
 		throw new QRCodeException(sprintf('invalid version number: %d', $version));
 		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
src/Data/QRData.php

@@ -140,7 +140,7 @@ final class QRData{
 
 
 		foreach($this->dataSegments as $segment){
 		foreach($this->dataSegments as $segment){
 			// data length in bits of the current segment +4 bits for each mode descriptor
 			// 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){
 			if(!$segment instanceof ECI){
 				// mode length bits margin to the next breakpoint
 				// mode length bits margin to the next breakpoint

+ 0 - 7
tests/Common/ModeTest.php

@@ -54,11 +54,4 @@ final class ModeTest extends TestCase{
 		Mode::getLengthBitsForVersion(Mode::BYTE, 69);
 		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);
-	}
-
 }
 }