Download the PHP package setbased/typed-config without Composer
On this page you can find all versions of the php package setbased/typed-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download setbased/typed-config
More information about setbased/typed-config
Files in setbased/typed-config
Package typed-config
Short Description A lightweight and strong typed that supports PHP, INI, XML, JSON, and YAML files
License MIT
Informations about the package typed-config
Strong Typed Config
A lightweight and strong typed configuration file loader that supports PHP, INI, XML, JSON, and YAML files.
This package is a wrapper around hassankhan/config.
Social | Legal | Release | Tests | Code |
---|---|---|---|---|
|
|
Manual
Instantiating Strong Typed Config
Creating an instance of Strong Typed Config requires passing an instance of :
Getting the value of a key
There are two flavors of methods for getting a configuration value:
- Mandatory keys (man for short). These methods will never return a null value.
- Optional keys (opt for short). These methods will return null if the key does not exists or has value .
All methods will try to cast the value of a key to the required type using package setbased/helper-cast. I.e. if the value of key is method will return and method will return .
All methods have two arguments:
- The key.
- An optional default value. this value will be returned if the key does not exists or has value .
The table below gives an overview of all methods for getting the value of a key.
Method | Null Value | Return Type |
---|---|---|
getManArray | throws an exception | array |
getManBool | throws an exception | bool |
getManFiniteFloat | throws an exception | float |
getManFloat | throws an exception | float |
getManInt | throws an exception | int |
getManString | throws an exception | string |
getOptArray | returns null | array|null |
getOptBool | returns null | bool|null |
getOptFiniteFloat | returns null | float|null |
getOptFloat | returns null | float|null |
getOptInt | returns null | int|null |
getOptString | returns null | string|null |
Installation
Strong Typed Config can be installed using composer:
License
This project is licensed under the terms of the MIT license.