State::__construct()

The constructor.

Table of Contents
  1. Description
  2. Example

Description

State::__construct(array $value = []): self;

This method will be called when you instantiate a State class. Instantiating this class to a different variable will not create a new container due to its static architecture. To create a new container, you need to extend this class to another class.

Example

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

echo $state->test; // Returns `2`
echo $storage->test; // Returns `2`
class Storage extends State {}

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

echo $state->test; // Returns `1`
echo $storage->test; // Returns `2`

State::__construct()

The constructor.