daux.io/libs/Config.php

34 regels
701 B
PHP

<?php namespace Todaymade\Daux;
use ArrayObject;
2015-07-17 23:38:06 +02:00
class Config extends ArrayObject
{
/**
* Merge an array into the object
*
* @param array $newValues
* @param bool $override
*/
public function merge($newValues, $override = true)
{
foreach ($newValues as $key => $value) {
2015-07-17 23:38:06 +02:00
if ($override === false && array_key_exists($key, $this)) {
continue;
}
$this[$key] = $value;
}
}
2015-07-17 23:38:06 +02:00
/**
* Merge an array into the object, ignore already added keys.
*
* @param $newValues
*/
public function conservativeMerge($newValues)
{
$this->merge($newValues, false);
}
}