NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class ClearBucket

Class used to clear the contents of a bucket or the results of an iterator

  Guzzle\Common\AbstractHasDispatcher implements Guzzle\Common\HasDispatcherInterface
  Aws\S3\Model\ClearBucket

Namespace: Aws\S3\Model
Located at Aws/S3/Model/ClearBucket.php

## Methods summary

- `public` `__construct ( Aws\Common\Client\AwsClientInterface $client, string $bucket )`
- `public static` `getAllEvents ( )`

  Get a list of all of the events emitted from the class

- `public` `setBucket ( string $bucket )`

  Set the bucket that is to be cleared

- `public` `getIterator ( )`

  Get the iterator used to yield the keys to be deleted. A default iterator will be created and returned if no iterator has been explicitly set.

- `public` `setIterator ( Iterator $iterator )`

  Sets a different iterator to use than the default iterator. This can be helpful when you wish to delete only specific keys from a bucket (e.g. keys that match a certain prefix or delimiter, or perhaps keys that pass through a filtered, decorated iterator).

- `public` `setMfa ( string $mfa )`

  Set the MFA token to send with each request

- `public` `clear ( )`

  Clear the bucket

## Methods detail

# `public`
`__construct( `Aws\Common\Client\AwsClientInterface` $client, string $bucket )`

#### Parameters

$client
  ``Aws\Common\Client\AwsClientInterface``
  $client Client used to execute requests
$bucket
  `string`
  $bucket Name of the bucket to clear

# `public static array`
`getAllEvents( )`

Get a list of all of the events emitted from the class

#### Returns

`array`

#### Overrides

`Guzzle\Common\AbstractHasDispatcher::getAllEvents`
# `public mixed`
`setBucket( string $bucket )`

Set the bucket that is to be cleared

#### Parameters

$bucket
  `string`
  $bucket Name of the bucket to clear

#### Returns

`mixed`
$this
# `public `Iterator``
`getIterator( )`

Get the iterator used to yield the keys to be deleted. A default iterator will be created and returned if no iterator has been explicitly set.

#### Returns

``Iterator``
# `public mixed`
`setIterator( `Iterator` $iterator )`

Sets a different iterator to use than the default iterator. This can be helpful when you wish to delete only specific keys from a bucket (e.g. keys that match a certain prefix or delimiter, or perhaps keys that pass through a filtered, decorated iterator).

#### Parameters

$iterator
  ``Iterator``
  $iterator Iterator used to yield the keys to be deleted

#### Returns

`mixed`
$this
# `public mixed`
`setMfa( string $mfa )`

Set the MFA token to send with each request

#### Parameters

$mfa
  `string`
  $mfa MFA token to send with each request. The value is the concatenation of the authentication device's serial number, a space, and the value displayed on your authentication device.

#### Returns

`mixed`
$this
# `public integer`
`clear( )`

Clear the bucket

#### Returns

`integer`
Returns the number of deleted keys

#### Throws

``Guzzle\Common\Exception\ExceptionCollection``

### Methods inherited from Guzzle\Common\AbstractHasDispatcher

`addSubscriber()`, `dispatch()`, `getEventDispatcher()`, `setEventDispatcher()`

### Magic methods summary

## Constants summary

`string` | `AFTER_DELETE` | `'clear_bucket.after_delete'` | # Event emitted when a batch request has completed
`string` | `BEFORE_CLEAR` | `'clear_bucket.before_clear'` | # Event emitted before the bucket is cleared
`string` | `AFTER_CLEAR` | `'clear_bucket.after_clear'` | # Event emitted after the bucket is cleared

## Properties summary

`protected `Aws\Common\Client\AwsClientInterface`` | $client | # Client used to execute the requests
`protected AbstractS3ResourceIterator` | $iterator | # Iterator used to yield keys
`protected string` | $mfa | # MFA used with each request

### Properties inherited from Guzzle\Common\AbstractHasDispatcher

`$eventDispatcher`