/**
  * Constructor
  *
  * @author Art <*****@*****.**>
  *
  * @param array $defaults The default config of extending classes
  * @param array $cfg      Default configuration overrides
  */
 public function __construct(array $defaults = [], array $cfg = [])
 {
     self::setDefaults();
     parent::__construct(array_merge(self::$defaults, $defaults), $cfg);
 }
Exemple #2
0
 /**
  * Sets a configuration key
  *
  * @author Art <*****@*****.**>
  *
  * @param string $k The config key
  * @param mixed  $v The config value
  *
  * @return self
  * @throws InvalidArgumentException if a parameter is... invalid.
  */
 public function set($k, $v)
 {
     switch ($k) {
         case self::LOG_LABEL:
             $ok = $this->checkLogLabel($v);
             $e = InvalidArgumentException::E_LABEL;
             break;
         case self::LOG_LEVEL:
             $ok = $this->checkLogLevel($v);
             $e = InvalidArgumentException::E_LEVEL;
             break;
         case self::SAVE_PATH:
             $ok = $this->checkSavePath($v);
             $e = InvalidArgumentException::E_PATH;
             break;
         default:
             $e = 0;
             $ok = true;
     }
     if ($ok) {
         parent::set($k, $v);
     } else {
         throw new InvalidArgumentException('The ' . $k . ' setting is invalid.', $e);
     }
     return $this;
 }
Exemple #3
0
 /**
  * Constructor
  *
  * @author Art <*****@*****.**>
  *
  * @param array $cfg Your custom config overrides
  */
 public function __construct(array $cfg = [])
 {
     self::setDefaultConfig();
     parent::__construct(self::$defaults, $cfg);
 }