/
configurator.php
50 lines (40 loc) · 1000 Bytes
/
configurator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace mageekguy\atoum;
class configurator
{
protected $script = null;
protected $methods = array();
public function __construct(scripts\runner $script)
{
$this->script = $script;
foreach ($this->script->getHelp() as $help)
{
list($arguments, $values) = $help;
foreach ($arguments as $argument)
{
$this->methods[preg_replace('/-(.)/e', 'ucfirst(\'\1\')', ltrim($argument, '-'))] = $argument;
}
}
}
public function __call($method, $arguments)
{
if (isset($this->methods[$method]) === false)
{
if (method_exists($this->script, $method) === false)
{
throw new exceptions\runtime\unexpectedValue('Method \'' . $method . '\' is unavailable');
}
call_user_func_array(array($this->script, $method), $arguments);
return $this;
}
else
{
$this->script->getArgumentsParser()->invokeHandlers($this->script, $this->methods[$method], $arguments);
return $this;
}
}
public function getScript()
{
return $this->script;
}
}