private function validateSemanticVersion($theVersion)
  {
    /**
     * Notice:
     * Version validation http://semver.org/
     * Example:
     * Valid version numbers: 1, 1.2, 2.2.3, 1.2.6-alpha, 4.2.3-alpha.beta, 1.5.0-rc.1;
     * Invalid version numbers: 1., 1.2., 1beta, 4.5alpha, 1.2.3-rc_1;
     */
    $status = preg_match('/^(\d+)(?:\.(\d+))?(?:\.((\d+)(?:-([A-Za-z]+)(?:\.(\w+))?)?))?$/', $theVersion, $matches);

    $version = [];

    if ($status)
    {
      $version['version'] = $matches[0];
      $version['major']   = $matches[1];
      $version['minor']   = $matches[2];

      // The above regexp will put the pre-release part in the patch part. Separate patch and pre-release part using
      // ordinary string manipulation.
      $pos = strpos($matches[3], '-');
      if ($pos!==false)
      {
        $version['patch']       = substr($matches[3], 0, $pos);
        $version['pre-release'] = substr($matches[3], $pos + 1);
      }
      else
      {
        $version['patch']       = $matches[3];
        $version['pre-release'] = '';
      }

      $version['release'] = $version['major'].'.'.$version['minor'].'.'.$version['patch'];
    }

    return $version;
  }
private function validateSemanticVersion($theVersion)
  {
    /**
     * Notice:
     * Version validation http://semver.org/
     * Example:
     * Valid version numbers: 1, 1.2, 2.2.3, 1.2.6-alpha, 4.2.3-alpha.beta, 1.5.0-rc.1;
     * Invalid version numbers: 1., 1.2., 1beta, 4.5alpha, 1.2.3-rc_1;
     */
    $status = preg_match('/^(\d+)(?:\.(\d+))?(?:\.((\d+)(?:-([A-Za-z]+)(?:\.(\w+))?)?))?$/', $theVersion, $matches);

    $version = [];

    if ($status)
    {
      $version['version'] = $matches[0];
      $version['major']   = $matches[1];
      $version['minor']   = $matches[2];

      // The above regexp will put the pre-release part in the patch part. Separate patch and pre-release part using
      // ordinary string manipulation.
      $pos = strpos($matches[3], '-');
      if ($pos!==false)
      {
        $version['patch']       = substr($matches[3], 0, $pos);
        $version['pre-release'] = substr($matches[3], $pos + 1);
      }
      else
      {
        $version['patch']       = $matches[3];
        $version['pre-release'] = '';
      }

      $version['release'] = $version['major'].'.'.$version['minor'].'.'.$version['patch'];
    }

    return $version;
  }
private function validateSemanticVersion ( $ theVersion ) { /**
     * Notice:
     * Version validation http://semver.org/
     * Example:
     * Valid version numbers: 1, 1.2, 2.2.3, 1.2.6-alpha, 4.2.3-alpha.beta, 1.5.0-rc.1;
     * Invalid version numbers: 1., 1.2., 1beta, 4.5alpha, 1.2.3-rc_1;
     */ $ status = preg_match ( '/^(\d+)(?:\.(\d+))?(?:\.((\d+)(?:-([A-Za-z]+)(?:\.(\w+))?)?))?$/' , $ theVersion , $ matches ) ; $ version = [ ] ; if ( $ status ) { $ version [ 'version' ] = $ matches [ 0 ] ; $ version [ 'major' ] = $ matches [ 1 ] ; $ version [ 'minor' ] = $ matches [ 2 ] ; // The above regexp will put the pre-release part in the patch part. Separate patch and pre-release part using // ordinary string manipulation. $ pos = strpos ( $ matches [ 3 ] , '-' ) ; if ( $ pos !== false ) { $ version [ 'patch' ] = substr ( $ matches [ 3 ] , 0 , $ pos ) ; $ version [ 'pre-release' ] = substr ( $ matches [ 3 ] , $ pos + 1 ) ; } else { $ version [ 'patch' ] = $ matches [ 3 ] ; $ version [ 'pre-release' ] = '' ; } $ version [ 'release' ] = $ version [ 'major' ] . '.' . $ version [ 'minor' ] . '.' . $ version [ 'patch' ] ; } return $ version ; }
Validates a string is a valid Semantic Version. If the string is semantic version returns an array with the parts
of the semantic version. Otherwise returns null.

@param string $theVersion The string the be validated.

@return array
Validates a string is a valid Semantic Version . If the string is semantic version returns an array with the parts of the semantic version . Otherwise returns null .