for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GeekLab\Conf\Driver;
final class INIConfDriver implements ConfDriverInterface
{
private string $mainConfFile; // Path and file name of the top configuration file.
private string $confLocation; // Path of the configuration files
/**
* INIConfDriver constructor.
*
* @param string $mainConfFile
* @param string $confLocation
*/
public function __construct(string $mainConfFile, string $confLocation)
$this->mainConfFile = $mainConfFile;
$this->confLocation = $confLocation;
}
* Load and parse a configuration file and return an array.
* @param string | null $file If null, then load the main configuration file
* @return array
public function parseConfigurationFile(?string $file = null): array
$fileName = $file === null ? $this->mainConfFile : $this->confLocation . $file . '.ini';
$parsed = parse_ini_file($fileName, $file !== null);
return !empty($parsed) ? $parsed : [];