szurubooru/tests/ConfigMock.php
Marcin Kurczewski 632bac8661 Added "use ..." statements
This version ditches backwards compatibility with PHP earlier than 5.6.
2014-10-18 18:48:36 +02:00

20 lines
430 B
PHP

<?php
namespace Szurubooru\Tests;
use Szurubooru\Config;
final class ConfigMock extends Config
{
public function set($key, $value)
{
$keys = preg_split('/[\\/]/', $key);
$current = $this;
$lastKey = array_pop($keys);
foreach ($keys as $key)
{
if (!isset($current->$key))
$current->$key = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
$current = $current->$key;
}
$current->$lastKey = $value;
}
}