Ejemplo n.º 1
0
 public function testDecodeWithMisRead()
 {
     $expected = FormatInformation::decodeFormatInformation($this->maskedTestFormatInfo, $this->maskedTestFormatInfo);
     $this->assertEquals($expected, FormatInformation::decodeFormatInformation($this->maskedTestFormatInfo ^ 0x3, $this->maskedTestFormatInfo ^ 0xf));
 }
Ejemplo n.º 2
0
 /**
  * Decodes version information from an integer and returns the version.
  *
  * @param  integer $versionBits
  * @return Version|null
  */
 public static function decodeVersionInformation($versionBits)
 {
     $bestDifference = PHP_INT_MAX;
     $bestVersion = 0;
     foreach (self::$versionDecodeInfo as $i => $targetVersion) {
         if ($targetVersion === $versionBits) {
             return self::getVersionForNumber($i + 7);
         }
         $bitsDifference = FormatInformation::numBitsDiffering($versionBits, $targetVersion);
         if ($bitsDifference < $bestDifference) {
             $bestVersion = $i + 7;
             $bestDifference = $bitsDifference;
         }
     }
     if ($bestDifference <= 3) {
         return self::getVersionForNumber($bestVersion);
     }
     return null;
 }