Storage/src/Lifecycle.php
public function clearRules($action = null)
    {
        if (!$action) {
            $this->lifecycle = [];
            return $this;
        }

        if (!is_string($action) && !is_callable($action)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Expected either a string or callable, instead got \'%s\'.',
                    gettype($action)
                )
            );
        }

        if (isset($this->lifecycle['rule'])) {
            if (is_string($action)) {
                $action = function ($rule) use ($action) {
                    return $rule['action']['type'] !== $action;
                };
            }

            $this->lifecycle['rule'] = array_filter(
                $this->lifecycle['rule'],
                $action
            );

            if (!$this->lifecycle['rule']) {
                $this->lifecycle = [];
            }
        }

        return $this;
    }
public function clearRules($action = null)
    {
        if (!$action) {
            $this->lifecycle = [];
            return $this;
        }

        if (!is_string($action) && !is_callable($action)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Expected either a string or callable, instead got \'%s\'.',
                    gettype($action)
                )
            );
        }

        if (isset($this->lifecycle['rule'])) {
            if (is_string($action)) {
                $action = function ($rule) use ($action) {
                    return $rule['action']['type'] !== $action;
                };
            }

            $this->lifecycle['rule'] = array_filter(
                $this->lifecycle['rule'],
                $action
            );

            if (!$this->lifecycle['rule']) {
                $this->lifecycle = [];
            }
        }

        return $this;
    }
public function clearRules ( $ action = null ) { if ( ! $ action ) { $ this -> lifecycle = [ ] ; return $ this ; } if ( ! is_string ( $ action ) && ! is_callable ( $ action ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected either a string or callable, instead got \'%s\'.' , gettype ( $ action ) ) ) ; } if ( isset ( $ this -> lifecycle [ 'rule' ] ) ) { if ( is_string ( $ action ) ) { $ action = function ( $ rule ) use ( $ action ) { return $ rule [ 'action' ] [ 'type' ] !== $ action ; } ; } $ this -> lifecycle [ 'rule' ] = array_filter ( $ this -> lifecycle [ 'rule' ] , $ action ) ; if ( ! $ this -> lifecycle [ 'rule' ] ) { $ this -> lifecycle = [ ] ; } } return $ this ; }
Clear all Object Lifecycle rules or rules of a certain action type.

Example:
```
// Remove all rules.
$lifecycle->clearRules();
```

```
// Remove all "Delete" based rules.
$lifecycle->clearRules('Delete');
```

```
// Clear any rules which have an age equal to 50.
$lifecycle->clearRules(function (array $rule) {
return $rule['condition']['age'] === 50
? false
: true;
});
```

@param string|callable $action [optional] If a string is provided, it
must be the name of the type of rule to remove (`SetStorageClass`
or `Delete`). All rules of this type will then be cleared. When
providing a callable you may define a custom route for how you
would like to remove rules. The provided callable will be run
through
[array_filter](http://php.net/manual/en/function.array-filter.php).
The callable's argument will be a single lifecycle rule as an
associative array. When returning true from the callable the rule
will be preserved, and if false it will be removed.
**Defaults to** `null`, clearing all assigned rules.
@return Lifecycle
@throws \InvalidArgumentException If a type other than a string or
callabe is provided.
Clear all Object Lifecycle rules or rules of a certain action type .