State::offsetExists()
Checks if a state with a certain key exists.
Table of Contents
Description
State::offsetExists(mixed $key): bool;
This method is a requirement to be able to implement the ArrayAccess
interface and aims to make the object data accessible using array access syntax. You won’t use this method directly, it will be executed automatically when you try to check the existence of a state with array access syntax. This method checks if a state with a certain key exists and will only work when checked using empty()
or isset()
language construct.
Example
$state = new State([
'bar' => 1,
'baz-qux' => 2,
'foo' => ""
]);
test(empty($state['asdf'])); // Returns `true`
test(empty($state['bar'])); // Returns `false`
test(empty($state['foo'])); // Returns `true`
test(isset($state['bar'])); // Returns `true`
test(isset($state['baz-qux'])); // Returns `true`
test(isset($state['bazQux'])); // Returns `false`
test(isset($state->bazQux)); // Returns `true` (see `State::__isset()`)
test(isset($state->{'baz-qux'})); // Returns `true` (see `State::__isset()`)
State::_()
The dynamic method initiator.
State::__call()
Calls a virtual method.
State::__callStatic()
Calls a virtual method statically.
State::__construct()
The constructor.
State::__get()
Gets a state via property access.
State::__invoke()
Proxy for the current object, called as a function.
State::__isset()
Checks if a state returns non-null value.
State::__serialize()
Provides data to be serialized.
State::__set()
Sets a state via property access.
State::__toString()
Proxy for the current object, casted as a string.
State::__unserialize()
Converts the serialized data back to its object.
State::__unset()
Deletes a state via property access.
State::count()
Counts the number of states.
State::get()
Gets a state or states.
State::getIterator()
The external iterator receiver.
State::jsonSerialize()
Returns the data to be serialized as JSON.
State::let()
Deletes a state or states.
State::offsetExists()
Checks if a state with a certain key exists.
State::offsetGet()
Gets a state using its key.
State::offsetSet()
Sets a state to the specified key.
State::offsetUnset()
Deletes a state at the specified key.
State::set()
Sets a state or states.