public static function decodeVersionInformation(int $versionBits) : ?self
    {
        $bestDifference = PHP_INT_MAX;
        $bestVersion = 0;

        foreach (self::VERSION_DECODE_INFO 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;
    }
public static function decodeVersionInformation(int $versionBits) : ?self
    {
        $bestDifference = PHP_INT_MAX;
        $bestVersion = 0;

        foreach (self::VERSION_DECODE_INFO 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;
    }
public static function decodeVersionInformation ( int $ versionBits ) : ? self { $ bestDifference = PHP_INT_MAX ; $ bestVersion = 0 ; foreach ( self :: VERSION_DECODE_INFO 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 ; }
Decodes version information from an integer and returns the version.
Decodes version information from an integer and returns the version .