abstract class AbstractOptions implements IOptionsAbstract (View source)

The GenericDatabase\Abstract\AbstractOptions class is an abstract base class implements the IOptionsAbstract interface and that provides a common interface for managing database connection options.

It allows dynamic setting and getting of options using a connection instance and an options array, and provides a base implementation for all options classes.

Main functionalities:

  • Provides a base class for managing database connection options.
  • Allows dynamic setting and getting of options using a connection instance and an options array.
  • Provides a common interface for all options classes.

Methods:

  • getInstance(): IConnection: Returns the static instance of IConnection.
  • set(string $name, mixed $value): void: Sets an option value dynamically by calling a method on the connection instance.
  • get(string $name): mixed: Retrieves an option value dynamically by calling a method on the connection instance.
  • getOptions(?int $type = null): mixed:Returns all options or a specific type of options if the$type` parameter is provided.

Fields:

  • $instance: The connection instance used for dynamic operations.
  • $options: The options handler for managing configuration.

Note that this class provides a structure for managing dynamic properties using a connection instance and options array. It allows setting and getting options dynamically by utilizing the Run::call method to invoke methods on the connection instance. Note that this class uses a static array $options to store connection options, and a static property $instance to store the database connection instance. The Run::call method is used to dynamically call methods on the connection instance.

Properties

static protected array $options

Array to store connection options

static protected IConnection $instance

Database connection instance

Methods

__construct(IConnection $instance)

Initialize options with a connection instance

getInstance()

Get the database connection instance

void
set(string $name, mixed $value)

Set an option value using dynamic method call

mixed
get(string $name)

Get an option value using dynamic method call

mixed
getOptions(int|null $type = null)

Get all options or a specific option type defined by user

Details

__construct(IConnection $instance)

Initialize options with a connection instance

Parameters

IConnection $instance

The database connection instance

IConnection getInstance()

Get the database connection instance

Return Value

IConnection

The current database connection instance

void set(string $name, mixed $value)

Set an option value using dynamic method call

Parameters

string $name

The name of the option to set

mixed $value

The value to set

Return Value

void

mixed get(string $name)

Get an option value using dynamic method call

Parameters

string $name

The name of the option to get

Return Value

mixed

The value of the requested option

mixed getOptions(int|null $type = null)

Get all options or a specific option type defined by user

Parameters

int|null $type

Optional type of options to retrieve

Return Value

mixed

All options or specific type options if type parameter provided