Inpsyde\MultilingualPress\Service\Exception\ContainerBootstrappedException::for_name PHP Method

for_name() public static method

Returns a new exception object.
Since: 3.0.0
public static for_name ( string $name, string $action = 'read' ) : static
$name string The name of the value or factory callback.
$action string Optional. Action to be performed. Defaults to 'read'.
return static Exception object.
    public static function for_name($name, $action = 'read')
    {
        return new static(sprintf('Cannot %2$s not shared "%1$s". The container has already been bootstrapped.', $name, $action));
    }

Usage Example

 /**
  * Returns the value or factory callback with the given name.
  *
  * @since 3.0.0
  *
  * @param string $name The name of a value or factory callback.
  *
  * @return mixed The value or factory callback with the given name.
  *
  * @throws ContainerValueNotSetException  if there is no value or factory callback with the given name.
  * @throws ContainerBootstrappedException if a not shared value or factory callback is to be accessed on a
  *                                        bootstrapped container.
  */
 public function offsetGet($name)
 {
     if (!$this->offsetExists($name)) {
         throw ContainerValueNotSetException::for_name($name, 'read');
     }
     if ($this->is_bootstrapped && !array_key_exists($name, $this->shared)) {
         throw ContainerBootstrappedException::for_name($name, 'read');
     }
     if (!array_key_exists($name, $this->values)) {
         $factory = $this->factories[$name];
         $this->values[$name] = $factory($this);
         if ($this->is_locked) {
             unset($this->factories[$name]);
         }
     }
     return $this->values[$name];
 }
ContainerBootstrappedException