Class Parameter
API parameter object used with service descriptions
Methods summary
-
public
__construct ( array $data = array(), Guzzle\Service\Description\ServiceDescriptionInterface $description = null )
Create a new Parameter using an associative array of data. The array can contain the following information:
- name: (string) Unique name of the parameter
- type: (string|array) Type of variable (string, number, integer, boolean,
object, array, numeric,
null, any). Types are using for validation and determining the structure of a parameter. You
can use a union type by providing an array of simple types. If one of the union types matches
the provided value, then the value is valid.
- instanceOf: (string) When the type is an object, you can specify the class that the object must implement
- required: (bool) Whether or not the parameter is required
- default: (mixed) Default value to use if no value is supplied
- static: (bool) Set to true to specify that the parameter value cannot be changed from the default
- description: (string) Documentation of the parameter
- location: (string) The location of a request used to apply a parameter.
Custom locations can be registered
with a command, but the defaults are uri, query, header, body, json, xml, postField, postFile.
- sentAs: (string) Specifies how the data being modeled is sent over the wire.
For example, you may wish
to include certain headers in a response model that have a normalized casing of FooBar, but the
actual header is x-foo-bar. In this case, sentAs would be set to x-foo-bar.
- filters: (array) Array of static method names to to run a parameter value
through. Each value in the
array must be a string containing the full class path to a static method or an array of complex
filter information. You can specify static methods of classes using the full namespace class
name followed by '::' (e.g. Foo\Bar::baz()). Some filters require arguments in order to properly
filter a value. For complex filters, use a hash containing a 'method' key pointing to a static
method, and an 'args' key containing an array of positional arguments to pass to the method.
Arguments can contain keywords that are replaced when filtering a value: '@value' is replaced
with the value being validated, '@api' is replaced with the Parameter object.
- properties: When the type is an object, you can specify nested parameters
- additionalProperties: (array) This attribute defines a schema for all
properties that are not explicitly
defined in an object type definition. If specified, the value MUST be a schema or a boolean. If
false is provided, no additional properties are allowed beyond the properties defined in the
schema. The default value is an empty schema which allows any value for additional properties.
- items: This attribute defines the allowed items in an instance array, and
MUST be a schema or an array
of schemas. The default value is an empty schema which allows any value for items in the
instance array.
When this attribute value is a schema and the instance value is an array, then all the items
in the array MUST be valid according to the schema.
- pattern: When the type is a string, you can specify the regex pattern that a value must match
- enum: When the type is a string, you can specify a list of acceptable values
- minItems: (int) Minimum number of items allowed in an array
- maxItems: (int) Maximum number of items allowed in an array
- minLength: (int) Minimum length of a string
- maxLength: (int) Maximum length of a string
- minimum: (int) Minimum value of an integer
- maximum: (int) Maximum value of an integer
- data: (array) Any additional custom data to use when serializing, validating, etc
- format: (string) Format used to coax a value into the correct format when
serializing or unserializing.
You may specify either an array of filters OR a format, but not both.
Supported values: date-time, date, time, timestamp, date-time-http
- $ref: (string) String referencing a service description model. The parameter
is replaced by the
schema contained in the model.
-
public
toArray ( )
Convert the object to an array
-
public
getValue ( string $value )
Get the default or static value of the command based on a value
-
public
filter ( mixed $value )
Run a value through the filters OR format attribute associated with the parameter
-
public
getName ( )
Get the name of the parameter
-
public
getWireName ( )
Get the key of the parameter, where sentAs will supersede name if it is set
-
public
setName ( string $name )
Set the name of the parameter
-
public
getType ( )
Get the type(s) of the parameter
-
public
setType ( string|array $type )
Set the type(s) of the parameter
-
public
getRequired ( )
Get if the parameter is required
-
public
setRequired ( bool $isRequired )
Set if the parameter is required
-
public
getDefault ( )
Get the default value of the parameter
-
public
setDefault ( string|null $default )
Set the default value of the parameter
-
public
getDescription ( )
Get the description of the parameter
-
public
setDescription ( string $description )
Set the description of the parameter
-
public
getMinimum ( )
Get the minimum acceptable value for an integer
-
public
setMinimum ( int|null $min )
Set the minimum acceptable value for an integer
-
public
getMaximum ( )
Get the maximum acceptable value for an integer
-
public
setMaximum ( int $max )
Set the maximum acceptable value for an integer
-
public
getMinLength ( )
Get the minimum allowed length of a string value
-
public
setMinLength ( int|null $min )
Set the minimum allowed length of a string value
-
public
getMaxLength ( )
Get the maximum allowed length of a string value
-
public
setMaxLength ( int $max )
Set the maximum allowed length of a string value
-
public
getMaxItems ( )
Get the maximum allowed number of items in an array value
-
public
setMaxItems ( int $max )
Set the maximum allowed number of items in an array value
-
public
getMinItems ( )
Get the minimum allowed number of items in an array value
-
public
setMinItems ( int|null $min )
Set the minimum allowed number of items in an array value
-
public
getLocation ( )
Get the location of the parameter
-
public
setLocation ( string|null $location )
Set the location of the parameter
-
public
getSentAs ( )
Get the sentAs attribute of the parameter that used with locations to sentAs an attribute when it is being applied to a location.
-
public
setSentAs ( string|null $name )
Set the sentAs attribute
-
public
getData ( string|null $name = null )
Retrieve a known property from the parameter by name or a data property by name. When not specific name value is specified, all data properties will be returned.
-
public
setData ( string|array|null $nameOrData, mixed|null $data = null )
Set the extra data properties of the parameter or set a specific extra property
-
public
getStatic ( )
Get whether or not the default value can be changed
-
public
setStatic ( bool $static )
Set to true if the default value cannot be changed
-
public
getFilters ( )
Get an array of filters used by the parameter
-
public
setFilters ( array $filters )
Set the array of filters used by the parameter
-
public
addFilter ( string|array $filter )
Add a filter to the parameter
-
public
getParent ( )
Get the parent object (an
Guzzle\Service\Description\OperationInterface
orGuzzle\Service\Description\Parameter
-
public
setParent ( OperationInterface|Parameter|null $parent )
Set the parent object of the parameter
-
public
getProperties ( )
Get the properties of the parameter
-
public
getProperty ( string $name )
Get a specific property from the parameter
-
public
removeProperty ( string $name )
Remove a property from the parameter
-
public
addProperty ( Guzzle\Service\Description\Parameter $property )
Add a property to the parameter
-
public
getAdditionalProperties ( )
Get the additionalProperties value of the parameter
-
public
setAdditionalProperties ( bool|Parameter|null $additional )
Set the additionalProperties value of the parameter
-
public
setItems ( Guzzle\Service\Description\Parameter $items = null )
Set the items data of the parameter
-
public
getItems ( )
Get the item data of the parameter
-
public
getInstanceOf ( )
Get the class that the parameter must implement
-
public
setInstanceOf ( string|null $instanceOf )
Set the class that the parameter must be an instance of
-
public
getEnum ( )
Get the enum of strings that are valid for the parameter
-
public
setEnum ( array $enum = null )
Set the enum of strings that are valid for the parameter
-
public
getPattern ( )
Get the regex pattern that must match a value when the value is a string
-
public
setPattern ( string $pattern )
Set the regex pattern that must match a value when the value is a string
-
public
getFormat ( )
Get the format attribute of the schema
-
public
setFormat ( string $format )
Set the format attribute of the schema
Methods detail
public
__construct( array $data = array(), Guzzle\Service\Description\ServiceDescriptionInterface
$description = null )
Create a new Parameter using an associative array of data. The array can contain the following information:
- name: (string) Unique name of the parameter
- type: (string|array) Type of variable (string, number, integer, boolean, object, array, numeric, null, any). Types are using for validation and determining the structure of a parameter. You can use a union type by providing an array of simple types. If one of the union types matches the provided value, then the value is valid.
- instanceOf: (string) When the type is an object, you can specify the class that the object must implement
- required: (bool) Whether or not the parameter is required
- default: (mixed) Default value to use if no value is supplied
- static: (bool) Set to true to specify that the parameter value cannot be changed from the default
- description: (string) Documentation of the parameter
- location: (string) The location of a request used to apply a parameter. Custom locations can be registered with a command, but the defaults are uri, query, header, body, json, xml, postField, postFile.
- sentAs: (string) Specifies how the data being modeled is sent over the wire. For example, you may wish to include certain headers in a response model that have a normalized casing of FooBar, but the actual header is x-foo-bar. In this case, sentAs would be set to x-foo-bar.
- filters: (array) Array of static method names to to run a parameter value through. Each value in the array must be a string containing the full class path to a static method or an array of complex filter information. You can specify static methods of classes using the full namespace class name followed by '::' (e.g. Foo\Bar::baz()). Some filters require arguments in order to properly filter a value. For complex filters, use a hash containing a 'method' key pointing to a static method, and an 'args' key containing an array of positional arguments to pass to the method. Arguments can contain keywords that are replaced when filtering a value: '@value' is replaced with the value being validated, '@api' is replaced with the Parameter object.
- properties: When the type is an object, you can specify nested parameters
- additionalProperties: (array) This attribute defines a schema for all properties that are not explicitly defined in an object type definition. If specified, the value MUST be a schema or a boolean. If false is provided, no additional properties are allowed beyond the properties defined in the schema. The default value is an empty schema which allows any value for additional properties.
- items: This attribute defines the allowed items in an instance array, and MUST be a schema or an array of schemas. The default value is an empty schema which allows any value for items in the instance array. When this attribute value is a schema and the instance value is an array, then all the items in the array MUST be valid according to the schema.
- pattern: When the type is a string, you can specify the regex pattern that a value must match
- enum: When the type is a string, you can specify a list of acceptable values
- minItems: (int) Minimum number of items allowed in an array
- maxItems: (int) Maximum number of items allowed in an array
- minLength: (int) Minimum length of a string
- maxLength: (int) Maximum length of a string
- minimum: (int) Minimum value of an integer
- maximum: (int) Maximum value of an integer
- data: (array) Any additional custom data to use when serializing, validating, etc
- format: (string) Format used to coax a value into the correct format when serializing or unserializing. You may specify either an array of filters OR a format, but not both. Supported values: date-time, date, time, timestamp, date-time-http
- $ref: (string) String referencing a service description model. The parameter is replaced by the schema contained in the model.
Parameters
- $data
array
$data Array of data as seen in service descriptions- $description
Guzzle\Service\Description\ServiceDescriptionInterface
$description Service description used to resolve models if $ref tags are found
Throws
Convert the object to an array
Returns
array
Get the default or static value of the command based on a value
Parameters
- $value
string
$value Value that is currently set
Returns
mixed
Returns the value, a static value if one is present, or a default value
Run a value through the filters OR format attribute associated with the parameter
Parameters
- $value
mixed
$value Value to filter
Returns
mixed
Returns the filtered value
Get the name of the parameter
Returns
string
Get the key of the parameter, where sentAs will supersede name if it is set
Returns
string
Set the name of the parameter
Parameters
- $name
string
$name Name to set
Returns
Get the type(s) of the parameter
Returns
string|array
Set the type(s) of the parameter
Parameters
- $type
string|array
$type Type of parameter or array of simple types used in a union
Returns
Get if the parameter is required
Returns
boolean
Set if the parameter is required
Parameters
- $isRequired
boolean
$isRequired Whether or not the parameter is required
Returns
Get the default value of the parameter
Returns
string|null
Set the default value of the parameter
Parameters
- $default
string|null
$default Default value to set
Returns
Get the description of the parameter
Returns
string|null
Set the description of the parameter
Parameters
- $description
string
$description Description
Returns
Get the minimum acceptable value for an integer
Returns
integer|null
Set the minimum acceptable value for an integer
Parameters
- $min
integer|null
$min Minimum
Returns
Get the maximum acceptable value for an integer
Returns
integer|null
Set the maximum acceptable value for an integer
Parameters
- $max
integer
$max Maximum
Returns
Get the minimum allowed length of a string value
Returns
integer
Set the minimum allowed length of a string value
Parameters
- $min
integer|null
$min Minimum
Returns
Get the maximum allowed length of a string value
Returns
integer|null
Set the maximum allowed length of a string value
Parameters
- $max
integer
$max Maximum length
Returns
Get the maximum allowed number of items in an array value
Returns
integer|null
Set the maximum allowed number of items in an array value
Parameters
- $max
integer
$max Maximum
Returns
Get the minimum allowed number of items in an array value
Returns
integer
Set the minimum allowed number of items in an array value
Parameters
- $min
integer|null
$min Minimum
Returns
Get the location of the parameter
Returns
string|null
Set the location of the parameter
Parameters
- $location
string|null
$location Location of the parameter
Returns
Get the sentAs attribute of the parameter that used with locations to sentAs an attribute when it is being applied to a location.
Returns
string|null
Set the sentAs attribute
Parameters
- $name
string|null
$name Name of the value as it is sent over the wire
Returns
Retrieve a known property from the parameter by name or a data property by name. When not specific name value is specified, all data properties will be returned.
Parameters
- $name
string|null
$name Specify a particular property name to retrieve
Returns
array|mixed|null
public
Guzzle\Service\Description\Parameter
setData( string|array|null $nameOrData, mixed|null $data = null )
Set the extra data properties of the parameter or set a specific extra property
Parameters
- $nameOrData
string|array|null
$nameOrData The name of a specific extra to set or an array of extras to set- $data
mixed|null
$data When setting a specific extra property, specify the data to set for it
Returns
Get whether or not the default value can be changed
Returns
mixed|null
Set to true if the default value cannot be changed
Parameters
- $static
boolean
$static True or false
Returns
Get an array of filters used by the parameter
Returns
array
Set the array of filters used by the parameter
Parameters
- $filters
array
$filters Array of functions to use as filters
Returns
Add a filter to the parameter
Parameters
- $filter
string|array
$filter Method to filter the value through
Returns
Throws
public
Guzzle\Service\Description\OperationInterface
|Guzzle\Service\Description\Parameter
|null
getParent( )
Get the parent object (an Guzzle\Service\Description\OperationInterface
or Guzzle\Service\Description\Parameter
Returns
public
Guzzle\Service\Description\Parameter
setParent( Guzzle\Service\Description\OperationInterface
|Guzzle\Service\Description\Parameter
|null $parent )
Set the parent object of the parameter
Parameters
- $parent
Guzzle\Service\Description\OperationInterface
|Guzzle\Service\Description\Parameter
|null
$parent Parent container of the parameter
Returns
Get the properties of the parameter
Returns
array
Get a specific property from the parameter
Parameters
- $name
string
$name Name of the property to retrieve
Returns
Remove a property from the parameter
Parameters
- $name
string
$name Name of the property to remove
Returns
public
Guzzle\Service\Description\Parameter
addProperty( Guzzle\Service\Description\Parameter
$property )
Add a property to the parameter
Parameters
- $property
Guzzle\Service\Description\Parameter
$property Properties to set
Returns
Get the additionalProperties value of the parameter
Returns
boolean|Guzzle\Service\Description\Parameter
|null
public
Guzzle\Service\Description\Parameter
setAdditionalProperties( boolean|Guzzle\Service\Description\Parameter
|null $additional )
Set the additionalProperties value of the parameter
Parameters
- $additional
boolean|
Guzzle\Service\Description\Parameter
|null
$additional Boolean to allow any, an Parameter to specify a schema, or false to disallow
Returns
public
Guzzle\Service\Description\Parameter
setItems( Guzzle\Service\Description\Parameter
$items = null )
Set the items data of the parameter
Parameters
- $items
Guzzle\Service\Description\Parameter
|null
$items Items to set
Returns
Get the class that the parameter must implement
Returns
null|string
Set the class that the parameter must be an instance of
Parameters
- $instanceOf
string|null
$instanceOf Class or interface name
Returns
Get the enum of strings that are valid for the parameter
Returns
array|null
Set the enum of strings that are valid for the parameter
Parameters
- $enum
array|null
$enum Array of strings or null
Returns
Get the regex pattern that must match a value when the value is a string
Returns
string
Set the regex pattern that must match a value when the value is a string
Parameters
- $pattern
string
$pattern Regex pattern
Returns
Get the format attribute of the schema
Returns
string
Set the format attribute of the schema
Parameters
- $format
string
$format Format to set (e.g. date, date-time, timestamp, time, date-time-http)
Returns
Magic methods summary
Properties summary
protected
mixed
|
$name | |
protected
mixed
|
$description | |
protected
mixed
|
$serviceDescription | |
protected
mixed
|
$type | |
protected
mixed
|
$required | |
protected
mixed
|
$enum | |
protected
mixed
|
$pattern | |
protected
mixed
|
$minimum | |
protected
mixed
|
$maximum | |
protected
mixed
|
$minLength | |
protected
mixed
|
$maxLength | |
protected
mixed
|
$minItems | |
protected
mixed
|
$maxItems | |
protected
mixed
|
$default | |
protected
mixed
|
$static | |
protected
mixed
|
$instanceOf | |
protected
mixed
|
$filters | |
protected
mixed
|
$location | |
protected
mixed
|
$sentAs | |
protected
mixed
|
$data | |
protected
array
|
$properties | |
protected
mixed
|
$additionalProperties | |
protected
mixed
|
$items | |
protected
mixed
|
$parent | |
protected
mixed
|
$ref | |
protected
mixed
|
$format | |
protected
mixed
|
$propertiesCache |