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.
-
publictoArray ( )Convert the object to an array
-
publicgetValue ( string $value )Get the default or static value of the command based on a value
-
publicfilter ( mixed $value )Run a value through the filters OR format attribute associated with the parameter
-
publicgetName ( )Get the name of the parameter
-
publicgetWireName ( )Get the key of the parameter, where sentAs will supersede name if it is set
-
publicsetName ( string $name )Set the name of the parameter
-
publicgetType ( )Get the type(s) of the parameter
-
publicsetType ( string|array $type )Set the type(s) of the parameter
-
publicgetRequired ( )Get if the parameter is required
-
publicsetRequired ( bool $isRequired )Set if the parameter is required
-
publicgetDefault ( )Get the default value of the parameter
-
publicsetDefault ( string|null $default )Set the default value of the parameter
-
publicgetDescription ( )Get the description of the parameter
-
publicsetDescription ( string $description )Set the description of the parameter
-
publicgetMinimum ( )Get the minimum acceptable value for an integer
-
publicsetMinimum ( int|null $min )Set the minimum acceptable value for an integer
-
publicgetMaximum ( )Get the maximum acceptable value for an integer
-
publicsetMaximum ( int $max )Set the maximum acceptable value for an integer
-
publicgetMinLength ( )Get the minimum allowed length of a string value
-
publicsetMinLength ( int|null $min )Set the minimum allowed length of a string value
-
publicgetMaxLength ( )Get the maximum allowed length of a string value
-
publicsetMaxLength ( int $max )Set the maximum allowed length of a string value
-
publicgetMaxItems ( )Get the maximum allowed number of items in an array value
-
publicsetMaxItems ( int $max )Set the maximum allowed number of items in an array value
-
publicgetMinItems ( )Get the minimum allowed number of items in an array value
-
publicsetMinItems ( int|null $min )Set the minimum allowed number of items in an array value
-
publicgetLocation ( )Get the location of the parameter
-
publicsetLocation ( string|null $location )Set the location of the parameter
-
publicgetSentAs ( )Get the sentAs attribute of the parameter that used with locations to sentAs an attribute when it is being applied to a location.
-
publicsetSentAs ( string|null $name )Set the sentAs attribute
-
publicgetData ( 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.
-
publicsetData ( string|array|null $nameOrData, mixed|null $data = null )Set the extra data properties of the parameter or set a specific extra property
-
publicgetStatic ( )Get whether or not the default value can be changed
-
publicsetStatic ( bool $static )Set to true if the default value cannot be changed
-
publicgetFilters ( )Get an array of filters used by the parameter
-
publicsetFilters ( array $filters )Set the array of filters used by the parameter
-
publicaddFilter ( string|array $filter )Add a filter to the parameter
-
publicgetParent ( )Get the parent object (an
Guzzle\Service\Description\OperationInterfaceorGuzzle\Service\Description\Parameter -
publicsetParent ( OperationInterface|Parameter|null $parent )Set the parent object of the parameter
-
publicgetProperties ( )Get the properties of the parameter
-
publicgetProperty ( string $name )Get a specific property from the parameter
-
publicremoveProperty ( string $name )Remove a property from the parameter
-
publicaddProperty ( Guzzle\Service\Description\Parameter $property )Add a property to the parameter
-
publicgetAdditionalProperties ( )Get the additionalProperties value of the parameter
-
publicsetAdditionalProperties ( bool|Parameter|null $additional )Set the additionalProperties value of the parameter
-
publicsetItems ( Guzzle\Service\Description\Parameter $items = null )Set the items data of the parameter
-
publicgetItems ( )Get the item data of the parameter
-
publicgetInstanceOf ( )Get the class that the parameter must implement
-
publicsetInstanceOf ( string|null $instanceOf )Set the class that the parameter must be an instance of
-
publicgetEnum ( )Get the enum of strings that are valid for the parameter
-
publicsetEnum ( array $enum = null )Set the enum of strings that are valid for the parameter
-
publicgetPattern ( )Get the regex pattern that must match a value when the value is a string
-
publicsetPattern ( string $pattern )Set the regex pattern that must match a value when the value is a string
-
publicgetFormat ( )Get the format attribute of the schema
-
publicsetFormat ( 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
arrayGet the default or static value of the command based on a value
Parameters
- $value
string
$value Value that is currently set
Returns
mixedReturns 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
mixedReturns the filtered value
Get the name of the parameter
Returns
stringGet the key of the parameter, where sentAs will supersede name if it is set
Returns
stringSet the name of the parameter
Parameters
- $name
string
$name Name to set
Returns
Get the type(s) of the parameter
Returns
string|arraySet 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
booleanSet 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|nullSet the default value of the parameter
Parameters
- $default
string|null
$default Default value to set
Returns
Get the description of the parameter
Returns
string|nullSet the description of the parameter
Parameters
- $description
string
$description Description
Returns
Get the minimum acceptable value for an integer
Returns
integer|nullSet the minimum acceptable value for an integer
Parameters
- $min
integer|null
$min Minimum
Returns
Get the maximum acceptable value for an integer
Returns
integer|nullSet the maximum acceptable value for an integer
Parameters
- $max
integer
$max Maximum
Returns
Get the minimum allowed length of a string value
Returns
integerSet 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|nullSet 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|nullSet 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
integerSet 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|nullSet 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|nullSet 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|nullSet 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
arraySet 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
arrayGet 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|stringSet 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|nullSet 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
stringSet 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
stringSet 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 |