Class Env
Provides access to environmental values.
Environmental values are grouped into categories that are accessible through
different global variables in PHP. Environment access is available by several
static calls to the corresponding names of the global variables. Depending
on the type of global variable, special support functions may be available
to ease access. It is possible to extend the environment system for additional
globals by providing corresponding Env_
VariableName
classes.
-
Core\Object
implements
Core\Chainable
-
Core\Env
Namespace: Core
Package: Core\Env
Since:
3.1
Requires:
PHP 5.3
Version:
2.1
Located at Env.inc.php
Methods summary
public static
Core\Env_Field |Core\Value[] |mixed[]
|
#
__callStatic( string $group, array $keys )
Retrieves the environment interface for an environment group or
directly retrieves values from that group.
Retrieves the environment interface for an environment group or
directly retrieves values from that group.
Parameters
- $group
Environment group name to get interface of. Name is automatically
converted to uppercase and equals the called static function name.
- $keys
Array of call arguments. Determines the return type of the method.
If not provided or an empty array, the method returns the interface
object for the requested environmental group.
If a simple array with key names, an array is returned with the
environment group values for each key respectively, wrapped as
Core\Value instances. Example with conversion to integer from
value instance:
$number = Env::Post('numberInput')->int;
If a single value that itself is an associative array, each keys is
fetched from the environment group as a Core\Value instance and
then the array value is applied as a key path to transform the value
accordingly. This allows easy conversion from environmental values
by a single array definition. Example:
$request =
Env::Request(array (
'simpleString' => Value::String,
'anInteger' => Value::Integer,
'aStringObject' => Value::StringObject,
'aStringInUppercase' => Value::UppercaseString,
'convertedToArray' => 'toArray',
)
);
Returns
Since
3.1
|
protected static
string|null
|
#
_lookup( string $resourceName, string $section, string $key )
Lookups a value for a given key of a specified resource section.
Lookups a value for a given key of a specified resource section.
Parameters
- $resourceName
- Name of lookup table data file.
- $section
- Name of lookup table.
- $key
- Lookup table key to retrieve value for.
Returns
string|null Retrieved lookup table value of null , if the value does not exist.
Since
3.2
|
public static
string
|
#
encodeKeyName( string $keyName )
Encodes a string for use as an environmental key.
Encodes a string for use as an environmental key.
Parameters
- $keyName
- String to encode as an environmental key.
Returns
string Encoded string for use as an environmental key.
Since
3.1
|
public static
boolean
|
#
isCLI( )
Determines whether PHP is running in a command-line interface.
Determines whether PHP is running in a command-line interface.
Returns
boolean
true , if PHP runs in a command-line interface, otherwise false .
Since
3.1
|
public static
boolean
|
#
isHTTPS( )
Determines whether the script was queried through the HTTPS protocol.
Determines whether the script was queried through the HTTPS protocol.
Returns
boolean true , if script was queried through the HTTPS protocol, otherwise
false .
Since
3.1
|
public static
Core\Env_FileList |Core\Env_File
|
#
Files( string $key )
Returns the files interface for a given input name.
Returns the files interface for a given input name.
Parameters
- $key
- Name of file upload form field.
Returns
Since
3.1
|
public static
string
|
#
serverAPI( boolean|string $prettyName = null )
Returns the server API name or pretty name.
Returns the server API name or pretty name.
Parameters
- $prettyName
If set to true , the pretty name for the current server API is
returned. If a string is given, the string is treated as a server API
name and the corresponding pretty name will be returned.
Returns
string Server API name or pretty name.
Since
3.2
|
__autocreateFactory()
,
__call()
,
__processParameters()
,
__toString()
,
attachMethod()
,
chain()
,
getValueForKey()
,
getValueForKeyPath()
,
getValueForUndefinedKey()
,
hash()
,
issetValueForKey()
,
setValueForKey()
,
setValueForKeyPath()
,
setValueForUndefinedKey()
,
uuid()
Magic methods summary
public static
Core\Env_File
|
#
File( $key )
File environment access.
Parameters
Returns
|