80% of 151OPs |
100% of 23Lines |
66% of 29Branches |
46% of 13Paths |
| Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
|---|---|---|---|---|---|---|---|---|
| mageekguy\atoum\configurator::__construct() | 48 | 42% | 8 | 100% | 11 | 36% | 5 | 0% |
| mageekguy\atoum\configurator::__call() | 97 | 98% | 14 | 100% | 17 | 82% | 7 | 71% |
| mageekguy\atoum\configurator::getScript() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
| # | |
|---|---|
| 1 |
<?php |
| 2 |
|
| 3 |
namespace mageekguy\atoum; |
| 4 |
|
| 5 |
class configurator |
| 6 |
{
|
| 7 |
protected $script = null; |
| 8 |
protected $methods = array(); |
| 9 |
|
| 10 |
public function __construct(scripts\runner $script)100% |
| 11 |
{
|
| 12 |
$this->script = $script; |
| 13 |
|
| 14 |
foreach ($this->script->getHelp() as $help) |
| 15 |
{
|
| 16 |
list($arguments, $values) = $help; |
| 17 |
|
| 18 |
foreach ($arguments as $argument) |
| 19 |
{
|
| 20 |
$this->methods[strtolower(str_replace('-', '', $argument))] = $argument;
|
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
public function __call($method, $arguments)100% |
| 26 |
{
|
| 27 |
$keyMethod = strtolower($method); |
| 28 |
|
| 29 |
if (isset($this->methods[$keyMethod]) === true) |
| 30 |
{
|
| 31 |
if (isset($arguments[0]) === true && is_array($arguments[0]) === true) |
| 32 |
{
|
| 33 |
$arguments = $arguments[0]; |
| 34 |
} |
| 35 |
|
| 36 |
$this->script->getArgumentsParser()->invokeHandlers($this->script, $this->methods[$keyMethod], $arguments); |
| 37 |
|
| 38 |
return $this; |
| 39 |
} |
| 40 |
else |
| 41 |
{
|
| 42 |
if (method_exists($this->script, $keyMethod) === false) |
| 43 |
{
|
| 44 |
throw new exceptions\runtime\unexpectedValue('Method \'' . $method . '\' is unavailable');
|
| 45 |
} |
| 46 |
|
| 47 |
$return = call_user_func_array(array($this->script, $keyMethod), $arguments); |
| 48 |
|
| 49 |
return ($return === $this->script ? $this : $return); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
public function getScript()100% |
| 54 |
{
|
| 55 |
return $this->script; |
| 56 |
} |
| 57 |
} |