Scalr\Service\OpenStack\OpenStackConfig::parseIdentityVersion PHP Method

parseIdentityVersion() public static method

Parses the version of identity endpoint url
public static parseIdentityVersion ( string $keystone ) : integer | null
$keystone string The identity endpoint url
return integer | null Returns the major version number or NULL if it cannot be obtained from the specified URL
    public static function parseIdentityVersion($keystone)
    {
        $matches = [];
        preg_match_all('/\\/v(?P<major>\\d+)(?:\\.(?P<minor>\\d+))?/', $keystone, $matches);
        return array_shift($matches['major']);
    }

Usage Example

 public function _keystoneUrl($from, $to, $action)
 {
     switch ($action) {
         case static::ACT_CONVERT_TO_OBJECT:
             /* @var $from Entity\CloudCredentials */
             $to->keystoneUrl = $from->properties[Entity\CloudCredentialsProperty::OPENSTACK_KEYSTONE_URL];
             break;
         case static::ACT_CONVERT_TO_ENTITY:
             /* @var $to Entity\CloudCredentials */
             $to->properties[Entity\CloudCredentialsProperty::OPENSTACK_KEYSTONE_URL] = $from->keystoneUrl;
             $to->properties[Entity\CloudCredentialsProperty::OPENSTACK_IDENTITY_VERSION] = OpenStackConfig::parseIdentityVersion($from->keystoneUrl);
             break;
         case static::ACT_GET_FILTER_CRITERIA:
             return [[]];
     }
 }
All Usage Examples Of Scalr\Service\OpenStack\OpenStackConfig::parseIdentityVersion