src/Guzzle/Service/Description/ServiceDescription.php
protected function fromArray(array $config)
    {
        // Keep a list of default keys used in service descriptions that is later used to determine extra data keys
        static $defaultKeys = array('name', 'models', 'apiVersion', 'baseUrl', 'description');
        // Pull in the default configuration values
        foreach ($defaultKeys as $key) {
            if (isset($config[$key])) {
                $this->{$key} = $config[$key];
            }
        }

        // Account for the Swagger name for Guzzle's baseUrl
        if (isset($config['basePath'])) {
            $this->baseUrl = $config['basePath'];
        }

        // Ensure that the models and operations properties are always arrays
        $this->models = (array) $this->models;
        $this->operations = (array) $this->operations;

        // We want to add operations differently than adding the other properties
        $defaultKeys[] = 'operations';

        // Create operations for each operation
        if (isset($config['operations'])) {
            foreach ($config['operations'] as $name => $operation) {
                if (!($operation instanceof Operation) && !is_array($operation)) {
                    throw new InvalidArgumentException('Invalid operation in service description: '
                        . gettype($operation));
                }
                $this->operations[$name] = $operation;
            }
        }

        // Get all of the additional properties of the service description and store them in a data array
        foreach (array_diff(array_keys($config), $defaultKeys) as $key) {
            $this->extraData[$key] = $config[$key];
        }
    }
protected function fromArray(array $config)
    {
        // Keep a list of default keys used in service descriptions that is later used to determine extra data keys
        static $defaultKeys = array('name', 'models', 'apiVersion', 'baseUrl', 'description');
        // Pull in the default configuration values
        foreach ($defaultKeys as $key) {
            if (isset($config[$key])) {
                $this->{$key} = $config[$key];
            }
        }

        // Account for the Swagger name for Guzzle's baseUrl
        if (isset($config['basePath'])) {
            $this->baseUrl = $config['basePath'];
        }

        // Ensure that the models and operations properties are always arrays
        $this->models = (array) $this->models;
        $this->operations = (array) $this->operations;

        // We want to add operations differently than adding the other properties
        $defaultKeys[] = 'operations';

        // Create operations for each operation
        if (isset($config['operations'])) {
            foreach ($config['operations'] as $name => $operation) {
                if (!($operation instanceof Operation) && !is_array($operation)) {
                    throw new InvalidArgumentException('Invalid operation in service description: '
                        . gettype($operation));
                }
                $this->operations[$name] = $operation;
            }
        }

        // Get all of the additional properties of the service description and store them in a data array
        foreach (array_diff(array_keys($config), $defaultKeys) as $key) {
            $this->extraData[$key] = $config[$key];
        }
    }
protected function fromArray ( array $ config ) { // Keep a list of default keys used in service descriptions that is later used to determine extra data keys static $ defaultKeys = array ( 'name' , 'models' , 'apiVersion' , 'baseUrl' , 'description' ) ; // Pull in the default configuration values foreach ( $ defaultKeys as $ key ) { if ( isset ( $ config [ $ key ] ) ) { $ this -> { $ key } = $ config [ $ key ] ; } } // Account for the Swagger name for Guzzle's baseUrl if ( isset ( $ config [ 'basePath' ] ) ) { $ this -> baseUrl = $ config [ 'basePath' ] ; } // Ensure that the models and operations properties are always arrays $ this -> models = ( array ) $ this -> models ; $ this -> operations = ( array ) $ this -> operations ; // We want to add operations differently than adding the other properties $ defaultKeys [ ] = 'operations' ; // Create operations for each operation if ( isset ( $ config [ 'operations' ] ) ) { foreach ( $ config [ 'operations' ] as $ name => $ operation ) { if ( ! ( $ operation instanceof Operation ) && ! is_array ( $ operation ) ) { throw new InvalidArgumentException ( 'Invalid operation in service description: ' . gettype ( $ operation ) ) ; } $ this -> operations [ $ name ] = $ operation ; } } // Get all of the additional properties of the service description and store them in a data array foreach ( array_diff ( array_keys ( $ config ) , $ defaultKeys ) as $ key ) { $ this -> extraData [ $ key ] = $ config [ $ key ] ; } }
Initialize the state from an array

@param array $config Configuration data
@throws InvalidArgumentException
Initialize the state from an array