AbstractStaticContainer

namespace

bhenk\doc2rst\globals

predicates

Abstract

implements

ContainerInterface | Stringable

known subclasses

RunConfiguration

Base class for static container classes that load their values from an Array

Implementations of this abstract static container use a UnitEnum to correlate their properties to keys in the array in a way that

property name == enum->name == key
method name == [get|set] + camelcase(property name)

@inheritdoc

Describes the interface of a container that exposes methods to read its entries

@inheritdoc from interface ContainerInterface


Methods

AbstractStaticContainer::enumForName

predicates

public | static | abstract

Returns the enum case for the given param $id or null if it does not exist

public static abstract function enumForName(
      Parameter #0 [ <required> string $id ]
 ): ?UnitEnum
param string $id - enum name
return ?UnitEnum - enum case with the given param $id or null

AbstractStaticContainer::get

predicates

public

implements

ContainerInterface::get

@inheritdoc

Finds an entry of the container by its identifier and returns it

param string $id - Identifier of the entry to look for.
return mixed - Entry.
throws NotFoundExceptionInterface - No entry was found for this identifier.
throws ContainerExceptionInterface - Error while retrieving the entry.

@inheritdoc from method ContainerInterface::get

public function get(
      Parameter #0 [ <required> string $id ]
 ): mixed
param string $id
return mixed

AbstractStaticContainer::has

predicates

public

implements

ContainerInterface::has

@inheritdoc

Returns true if the container can return an entry for the given identifier

Returns false otherwise.

has($id) returning true does not mean that get($id) will not throw an exception. It does however mean that get($id) will not throw a NotFoundExceptionInterface.

param string $id - Identifier of the entry to look for.
return bool

@inheritdoc from method ContainerInterface::has

public function has(
      Parameter #0 [ <required> string $id ]
 ): bool
param string $id
return bool

AbstractStaticContainer::__toString

predicates

public

implements

Stringable::__toString

Returns a string representation of this container

public function __toString(): string
return string

AbstractStaticContainer::load

predicates

public | static

Load the container with the given configuration

Keys in the array configuration should correspond to the names of cases in the UnitEnum given by AbstractStaticContainer::enumForName.

public static function load(
      Parameter #0 [ <required> array $configuration ]
 ): void
param array $configuration
return void
throws ContainerException - if array in param $configuration not correct

AbstractStaticContainer::toArray

predicates

public | static

Returns an array representing the container

public static function toArray(): array
return array - array representing the container

AbstractStaticContainer::reset

predicates

public | static

Reset the container to a neutral state (not necessarily to its original state)

public static function reset(): array
return array - representing the neutral state

AbstractStaticContainer::getMethodName

predicates

public | static

Return the method name part corresponding to the given param $id

Input of snake_like_name, output CamelCaseName:

foo_bar_name -> FooBarName
public static function getMethodName(
      Parameter #0 [ <required> string $id ]
 ): string
param string $id - snake_like_name
return string - CamelCaseName

Fri, 31 Mar 2023 13:22:46 +0000