<?php
namespace Yesf\Config\Adapter;
use Yesf\Yesf;
use Yesf\Config\ConfigTrait;
use Yesf\Config\ConfigInterface;
class Yaconf implements ConfigInterface {
use ConfigTrait;
protected $appName;
protected $environment;
public function __construct($appName = null) {
$this->appName = $appName;
$this->environment = Yesf::app()->getEnvironment();
}
protected function getKey($key) {
$key = $this->environment . '.' . $key;
if (!empty($this->appName)) {
$key = $this->appName . '.' . $key;
}
return $key;
}
public function get($key, $default = null) {
$key = $this->getKey($key);
return Yaconf::has($key) ? Yaconf::get($key) : $default;
}
public function has($key) {
$key = $this->getKey($key);
return Yaconf::has($key);
}
}