com\setasign\SetaFramework\Config

Config Class Config

File: /SetaFramework/src/Config/Config.php

Class hierarchy

Implements

Summary

Properties

$config

protected array Config::$config

Contains the configuration

$readOnly

protected bool Config::$readOnly

Variable for the readOnly option of a Config


Static Methods

createReader()

protected static Config::createReader (
string $file,
array $params = array ( )
): Reader\ReaderInterface
Parameters
$file : string
 
$params : array
 

read()

public static Config::read (
string $file,
array $params = array ( ),
bool $readOnly = false
): Config

Reads a config file.

Which $params are possible depends on $file. The params will be passed in the given order. Only the internal order will be used, not the keys.

Supported file types: .ini, .xml, .json, .php

Parameters
$file : string
 
$params : array
 
$readOnly : bool
 
Return Values

Result depends on $createConfig; If false $readOnly won't be used.


Methods

__construct()

public Config::__construct (
array|Reader\ReaderInterface $config = array ( ),
bool $readOnly = false
)

Constructor

Parameters
$config : array|Reader\ReaderInterface
 
$readOnly : bool
 

__clone()

public Config::__clone (
void
): void

Implementation of __clone()

__get()

public Config::__get (
int|string $key
): ?mixed

Magic get method to get a value

Parameters
$key : int|string
 
Exceptions

Throws \InvalidArgumentException

__isset()

public Config::__isset (
int|string $key
): bool
Parameters
$key : int|string
 

__set()

public Config::__set (
int|string $key,
mixed $value
): void

Magic set method to set a value

Parameters
$key : int|string
 
$value : mixed
 

__toString()

public Config::__toString (
void
): string

toString will parse the config into json

__unset()

public Config::__unset (
int|string $key
): void
Parameters
$key : int|string
 

count()

public Config::count (
void
): int

Implementation of \Countable

See

delete()

public Config::delete (
int|string $key
): void

Deletes an entry or throws an exception if the config is marked as readOnly or the entry does not exist

Parameters
$key : int|string
 
Exceptions

Throws \InvalidArgumentException

Throws \BadMethodCallException

filter()

public Config::filter (
array<int|string> $allowedKeys
): Config
Parameters
$allowedKeys : array<int|string>
 
Return Values

A new filtered config instance

get()

public Config::get (
int|string|array $key,
mixed $default = null,
bool $chain = false
): ?mixed

Method to get an entry of the config. If the entry is not found, the default-value is returned.

Parameters
$key : int|string|array
 
$default : mixed
 
$chain : bool
 

getChain()

public Config::getChain (
int|string|array $keyChain,
mixed $default = null
): ?mixed

Helper method to get a value or the default of a nested config.

If the keyChain does not exist like specified the default will be returned.

$keyChain can be defined as string: '->' is the delimiter of the keys.

Parameters
$keyChain : int|string|array
 
$default : mixed

The default value.

getIterator()

public Config::getIterator (
void
): \Traversable

getSubConfig()

public Config::getSubConfig (
int|string|array $key,
bool $chain = false
): self
Parameters
$key : int|string|array
 
$chain : bool
 

has()

public Config::has (
int|string $key
): bool
Parameters
$key : int|string
 

hasChain()

public Config::hasChain (
int|string|array $keyChain
): bool

Helper method to check if a chain exists in a nested config.

$keyChain can be defined as string: '->' is the delimiter of the keys.

Parameters
$keyChain : int|string|array
 

in()

public Config::in (
mixed $needle,
bool $strict = false
): bool

Searches the config for needle using loose comparison unless strict is set

Parameters
$needle : mixed
 
$strict : bool
 

isReadOnly()

public Config::isReadOnly (
void
): bool

Checks whether this config is read-only

isSubConfig()

public Config::isSubConfig (
int|string|array $key,
bool $chain = false
): bool
Parameters
$key : int|string|array
 
$chain : bool
 

jsonSerialize()

public Config::jsonSerialize (
void
): array

keys()

public Config::keys (
void
): array

Returns all keys of the config

ksort()

public Config::ksort (
?int $sortFlags = null
): void
Parameters
$sortFlags : ?int
 

offsetExists()

public Config::offsetExists (
mixed $offset
): bool
Parameters
$offset : mixed
 

offsetGet()

public Config::offsetGet (
mixed $offset
): ?mixed
Parameters
$offset : mixed
 

offsetSet()

public Config::offsetSet (
mixed $offset,
mixed $value
): void
Parameters
$offset : mixed
 
$value : mixed
 

offsetUnset()

public Config::offsetUnset (
mixed $offset
): void
Parameters
$offset : mixed
 

push()

public Config::push (
mixed $value
): void
Parameters
$value : mixed
 

rand()

public Config::rand (
int $numReq = 1
): array|int|string

Picks one or more random entries out of an array, and returns the key (or keys) of the random entries.

Parameters
$numReq : int

Specifies how many entries should be picked.

Return Values

When picking only one entry, array_rand() returns the key for a random entry. Otherwise, an array of keys for the random entries is returned. This is done so that random keys can be picked from the array as well as random values. Trying to pick more elements than there are in the array will result in an E_WARNING level error, and NULL will be returned.

search()

public Config::search (
mixed $needle,
bool $strict = false
): false|int|string

Searches the array for a given value and returns the corresponding key if successful

Parameters
$needle : mixed

The searched value.

$strict : bool

If TRUE then the method will search for identical elements in the haystack. This means it will also check the types of the needle in the haystack, and objects must be the same instance.

set()

public Config::set (
int|string $key,
mixed $value
): void

Sets a value or throws an exception if the config is marked as readOnly

Parameters
$key : int|string
 
$value : mixed
 
Exceptions

Throws \BadMethodCallException

setReadOnly()

public Config::setReadOnly (
bool $readOnly = true
): void

Sets the read-only flag on this and all underlaying config-objects

Parameters
$readOnly : bool
 

sort()

public Config::sort (
?int $sortFlags = null
): void
Parameters
$sortFlags : ?int
 

toArray()

public Config::toArray (
bool $recursive = true
): array

Returns the configuration as a plain PHP array

Parameters
$recursive : bool
 

values()

public Config::values (
void
): array

Returns all values of the config