Installation guide

}
$isDeleted = (bool) $result->get('DeleteMarker');
Of course, you can still use isset() checks if you want to, since Model does implement ArrayAccess. The
model object (and underlying Collection object) also has convenience methods for finding and checking for keys and
values.
// You can use isset() since the object implements ArrayAccess
if (!isset($result['ContentLength'])) {
echo "Empty file.";
}
// There is also a method that does the same type of check
if (!$result->hasKey('ContentLength')) {
echo "Empty file.";
}
// If needed, you can search for a key in a case-insensitive manner
echo $result->keySearch('body');
//> Body
echo $result->keySearch('Body');
//> Body
// You can also list all of the keys in the result
var_export($result->getKeys());
//> array ( 'Body', 'DeleteMarker', 'Expiration', 'ContentLength', ... )
// The getAll() method will return the result data as an array
// You can specify a set of keys to only get a subset of the data
var_export($result->getAll(array('Body', 'ContentLength')));
//> array ( 'Body' => 'Hello!' , 'ContentLength' => 6 )
Getting nested values
The getPath() method of the model is useful for easily getting nested values from a response. The path is
specified as a series of keys separated by slashes.
// Perform a RunInstances operation and traverse into the results to get the InstanceId
$result = $ec2Client->runInstances(array(
'ImageId' => 'ami-548f13d',
'MinCount' => 1,
'MaxCount' => 1,
'InstanceType' => 't1.micro',
));
$instanceId = $result->getPath('Instances/0/InstanceId');
Wildcards are also supported so that you can get extract an array of data. The following example is a modification of
the preceding such that multiple InstanceIds can be retrieved.
// Perform a RunInstances operation and get an array of the InstanceIds that were created
$result = $ec2Client->runInstances(array(
'ImageId' => 'ami-548f13d',
'MinCount' => 3,
'MaxCount' => 5,
'InstanceType' => 't1.micro',
));
$instanceId = $result->getPath('Instances/*/InstanceId');
Using data in the model
Modeled Responses
38