PHP Class Bart\Configuration\Configuration

All children are required to define a README method which can be used to see how each class expects its conf files to look.
ファイルを表示 Open project: box/bart Class Usage Examples

Protected Properties

Property Type Description
$configurations array
$logger Logger

Public Methods

Method Description
README ( ) : string
__construct ( ) Instantiate instance configured to load configurations based on called class name
configure ( string $path )

Protected Methods

Method Description
configsPath ( ) : string
getArray ( $section, $key, array $default = [], $required = true ) : string[]
getBool ( $section, $key, $default = null, $required = true ) : boolean
getCurrentPassword ( string $prompt ) : string Prompt user for their user account's password
getCurrentUsername ( ) : string
getNumeric ( $section, $key, $default = null, $required = true ) http://stackoverflow.com/questions/12650802/php-equivalent-of-javascripts-parseint-function
getSecret ( string $section, string $key, string $prompt ) : string Prompt the user for secret input. Secret is cached in $section.$key for later retrieval.
getValue ( string $section, string $key, mixed $default = null, boolean $required = true ) : mixed
loadParsedIni ( string $filePath, string $subclass ) : array

Private Methods

Method Description
load ( ) : array Load the configurations from the config file for subclass
updateRuntimeConfiguration ( string $section, string $key, string $value ) Set in memory configs for $section[$key] = $value; this is used exclusively for caching secrets

Method Details

README() abstract public method

abstract public README ( ) : string
return string Sample of how configuration is intended to be defined

__construct() public method

Instantiate instance configured to load configurations based on called class name
public __construct ( )

configsPath() protected method

protected configsPath ( ) : string
return string Path to configurations

configure() public static method

public static configure ( string $path )
$path string Root path to all configuration

getArray() protected method

protected getArray ( $section, $key, array $default = [], $required = true ) : string[]
$default array
return string[] String list of value split by comma

getBool() protected method

protected getBool ( $section, $key, $default = null, $required = true ) : boolean
return boolean If the value equals the literal string "true"

getCurrentPassword() protected method

Prompt user for their user account's password
protected getCurrentPassword ( string $prompt ) : string
$prompt string Text to prompt the user
return string Current user's password

getCurrentUsername() protected method

protected getCurrentUsername ( ) : string
return string User name of effective user

getNumeric() protected method

http://stackoverflow.com/questions/12650802/php-equivalent-of-javascripts-parseint-function
protected getNumeric ( $section, $key, $default = null, $required = true )

getSecret() protected method

Prompt the user for secret input. Secret is cached in $section.$key for later retrieval.
protected getSecret ( string $section, string $key, string $prompt ) : string
$section string Section in which to use key to save secret in cache only
$key string Key name to associate with secret in cache only
$prompt string Text to prompt user input
return string Secret input from user

getValue() protected method

protected getValue ( string $section, string $key, mixed $default = null, boolean $required = true ) : mixed
$section string Configuration section in file
$key string Configuration key in section
$default mixed If not required, the default to use
$required boolean If an exception should be raised when value is missing
return mixed Configured value or default

loadParsedIni() protected method

protected loadParsedIni ( string $filePath, string $subclass ) : array
$filePath string Absolute path to file containing configurations
$subclass string Name of the configuration class
return array Contents of configuration parsed as INI with sections

Property Details

$configurations protected_oe property

protected array $configurations
return array

$logger protected_oe property

protected Logger $logger
return Logger