State::offsetUnset()

Deletes a state at the specified key.

Table of Contents
  1. Description
  2. Example

Description

State::offsetUnset(mixed $key): void;

This method is a requirement to be able to implement the ArrayAccess interface and aims to make the object data modifiable using array access syntax. You won’t use this method directly, it will be executed automatically when you try to delete a state with array access syntax. This method deletes a state at the specified key.

Example

$state = new State([
    'bar' => 1,
    'baz' => 2,
    'foo' => 3,
    'qux' => 4
]);

$state['bar'] = null;
unset($state['baz']);

test($state->get([], true)); // Returns `['bar' => null, 'foo' => 3, 'qux' => 4]`

State::offsetUnset()

Deletes a state at the specified key.