State::__get()

Gets a state via property access.

Table of Contents
  1. Description
  2. Example

Description

State::__get(string $key): mixed;

This method will first check if State::__call() returns a virtual method, if it returns a virtual method, this method will return the value of that virtual method. Other than that, this method will check if a state with the same key name as the method name is available. If it is available then this method will return that state.

Example

$state = new State(['test' => 1]);

$asdf = $state->asdf; // Returns `null`
$test = $state->test; // Returns `1`

Method name will be normalized by function p2f(), so when you try to access $state->dateFormat for example, internally you are trying to get a state with name date-format. This is also the same when you try to access $state->{'date-format'}. If no state is available, this method returns null.

State::__get()

Gets a state via property access.