Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Dynart\Micro; |
| 4 | |
| 5 | /** |
| 6 | * Config handler |
| 7 | * |
| 8 | * Loads INI files, caches the retrieved values |
| 9 | */ |
| 10 | interface ConfigInterface { |
| 11 | /** |
| 12 | * Loads an INI file and merges with current config |
| 13 | * |
| 14 | * It does NOT process sections! The "true", "false", "no", "yes", "on", "off" values |
| 15 | * will be replaced with true and false values. |
| 16 | * |
| 17 | * @param string $path The path of the INI file |
| 18 | */ |
| 19 | public function load(string $path): void; |
| 20 | |
| 21 | /** |
| 22 | * Clears the in-memory cache |
| 23 | */ |
| 24 | public function clearCache(): void; |
| 25 | |
| 26 | /** |
| 27 | * Returns with value from the configuration |
| 28 | * |
| 29 | * @param string $name The config name |
| 30 | * @param mixed $default The return value if the name does not exist in the configuration |
| 31 | * @param bool $useCache Use the cache for retrieving the value? |
| 32 | */ |
| 33 | public function get(string $name, mixed $default = null, bool $useCache = true): mixed; |
| 34 | |
| 35 | /** |
| 36 | * Returns with an array from a comma separated string config value |
| 37 | * |
| 38 | * For example: "1, 2, 3" will result in ['1', '2', '3'] |
| 39 | * |
| 40 | * @param string $name The config name |
| 41 | * @param bool $useCache Use the cache for retrieving the value? |
| 42 | */ |
| 43 | public function getCommaSeparatedValues(string $name, bool $useCache = true): array; |
| 44 | |
| 45 | /** |
| 46 | * Returns with an array from the config |
| 47 | * |
| 48 | * For example: with the following config: |
| 49 | * |
| 50 | * <pre> |
| 51 | * persons.0.name = "name1" |
| 52 | * persons.0.age = "32" |
| 53 | * persons.1.name = "name2" |
| 54 | * persons.1.age = "42" |
| 55 | * </pre> |
| 56 | * |
| 57 | * the result will be for `$config->getArray('persons')`: |
| 58 | * |
| 59 | * <pre> |
| 60 | * [ |
| 61 | * 0 => [ |
| 62 | * "name" => "name1", |
| 63 | * "age" => "32" |
| 64 | * ], |
| 65 | * 1 => [ |
| 66 | * "name" => "name2", |
| 67 | * "age" => "42" |
| 68 | * ] |
| 69 | * ] |
| 70 | * </pre> |
| 71 | */ |
| 72 | public function getArray(string $prefix, array $default = [], bool $useCache = true): array; |
| 73 | |
| 74 | /** |
| 75 | * Returns true if the config value is cached |
| 76 | * |
| 77 | * @param string $name Name of the config |
| 78 | * @return bool Is the config value cached? |
| 79 | */ |
| 80 | public function isCached(string $name): bool; |
| 81 | |
| 82 | /** |
| 83 | * Replaces the ~ symbol at the beginning of the path |
| 84 | * with the `app.root_path` config value |
| 85 | */ |
| 86 | public function getFullPath(string $path): string; |
| 87 | |
| 88 | /** |
| 89 | * Returns the application root path (`app.root_path` config value) |
| 90 | */ |
| 91 | public function rootPath(): string; |
| 92 | } |