for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace phpbu\App\Adapter;
use Dotenv\Dotenv as DotenvLib;
use phpbu\App\Adapter;
use phpbu\App\Configuration;
use phpbu\App\Exception;
use phpbu\App\Util;
/**
* PHPArray Adapter
*
* @package phpbu
* @subpackage App
* @author Sebastian Feldmann <[email protected]>
* @copyright Sebastian Feldmann <[email protected]>
* @license https://opensource.org/licenses/MIT The MIT License (MIT)
* @link http://phpbu.de/
* @since Class available since Release 4.0.1
*/
class PHPArray implements Adapter
{
* Path to the config file
* @var string
private $file;
* Configuration
* @var array
private $config;
* Setup the adapter.
* @param array $conf
* @return void
public function setup(array $conf)
$path = Util\Arr::getValue($conf, 'file', '.env');
$this->file = Util\Cli::toAbsolutePath($path, Configuration::getWorkingDirectory());
$this->load();
}
* Load config file to local file.
* @throws \phpbu\App\Exception
private function load()
if (!file_exists($this->file)) {
throw new Exception('config file not found');
$this->config = require $this->file;
* Return a value for a given path.
* @param string $path
* @return string
public function getValue($path)
$arrPath = explode('.', $path);
$data = $this->config;
foreach ($arrPath as $segment) {
if (!isset($data[$segment])) {
throw new Exception('invalid config path');
$data = $data[$segment];
return (string) $data;