szurubooru/tests/ConfigMock.php

21 lines
511 B
PHP
Raw Normal View History

2014-09-05 20:08:54 +02:00
<?php
namespace Szurubooru\Tests;
use Szurubooru\Config;
2014-09-05 20:08:54 +02:00
final class ConfigMock extends Config
2014-09-05 20:08:54 +02:00
{
2015-11-25 09:48:03 +01:00
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;
}
2014-09-05 20:08:54 +02:00
}