src/iOSbuild.php
public static function getVersion($needle) {
    self::populate();
    if (array_key_exists($needle, self::$BuildVer)) {
      return self::$BuildVer[$needle];
    }
    $builds   = array();
    $versions = array();
    foreach (self::$BuildVer as $code => $val) {
      $builds[]   = $code;
      $versions[] = $val;
    }
    $candidate = false;
    if (preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $needle, $matchNeedle)) {
      # Walk backwards
      $count = count($builds);
      for ($key = $count - 1; $key >= 0; $key--) {
        preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $builds[$key], $matchCode);
        if ($matchCode[1] . $matchCode[2] . $matchCode[3] == $matchNeedle[1] . $matchNeedle[2] . $matchNeedle[3]) {
          return $versions[$key];
        }
        if ($matchCode[1] . $matchCode[2] == $matchNeedle[1] . $matchNeedle[2] && $matchNeedle[3] > $matchCode[3]) {
          $candidate = $versions[$key];
        }
      }
    }
    if (!empty($candidate)) {
      return preg_replace('/b\d+$/', '', $candidate);
    }
    return $candidate;
  }
public static function getVersion($needle) {
    self::populate();
    if (array_key_exists($needle, self::$BuildVer)) {
      return self::$BuildVer[$needle];
    }
    $builds   = array();
    $versions = array();
    foreach (self::$BuildVer as $code => $val) {
      $builds[]   = $code;
      $versions[] = $val;
    }
    $candidate = false;
    if (preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $needle, $matchNeedle)) {
      # Walk backwards
      $count = count($builds);
      for ($key = $count - 1; $key >= 0; $key--) {
        preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $builds[$key], $matchCode);
        if ($matchCode[1] . $matchCode[2] . $matchCode[3] == $matchNeedle[1] . $matchNeedle[2] . $matchNeedle[3]) {
          return $versions[$key];
        }
        if ($matchCode[1] . $matchCode[2] == $matchNeedle[1] . $matchNeedle[2] && $matchNeedle[3] > $matchCode[3]) {
          $candidate = $versions[$key];
        }
      }
    }
    if (!empty($candidate)) {
      return preg_replace('/b\d+$/', '', $candidate);
    }
    return $candidate;
  }
public static function getVersion ( $ needle ) { self :: populate ( ) ; if ( array_key_exists ( $ needle , self :: $ BuildVer ) ) { return self :: $ BuildVer [ $ needle ] ; } $ builds = array ( ) ; $ versions = array ( ) ; foreach ( self :: $ BuildVer as $ code => $ val ) { $ builds [ ] = $ code ; $ versions [ ] = $ val ; } $ candidate = false ; if ( preg_match ( '/^(\d+)([A-Z])(\d+)([a-z])?$/' , $ needle , $ matchNeedle ) ) { # Walk backwards $ count = count ( $ builds ) ; for ( $ key = $ count - 1 ; $ key >= 0 ; $ key -- ) { preg_match ( '/^(\d+)([A-Z])(\d+)([a-z])?$/' , $ builds [ $ key ] , $ matchCode ) ; if ( $ matchCode [ 1 ] . $ matchCode [ 2 ] . $ matchCode [ 3 ] == $ matchNeedle [ 1 ] . $ matchNeedle [ 2 ] . $ matchNeedle [ 3 ] ) { return $ versions [ $ key ] ; } if ( $ matchCode [ 1 ] . $ matchCode [ 2 ] == $ matchNeedle [ 1 ] . $ matchNeedle [ 2 ] && $ matchNeedle [ 3 ] > $ matchCode [ 3 ] ) { $ candidate = $ versions [ $ key ] ; } } } if ( ! empty ( $ candidate ) ) { return preg_replace ( '/b\d+$/' , '' , $ candidate ) ; } return $ candidate ; }
Takes iOS build code and returns corresponding iOS version.
@param  string $needle
@return mixed
@throws \Exception
Takes iOS build code and returns corresponding iOS version .