for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Bankiru\Api\Rpc\Routing;
final class MatcherDumper
{
/**
* @param MethodCollection $collection
* @param array $options
*
* @return string
*/
public function dump(MethodCollection $collection, array $options)
$content =
<<<CONTENT
use Bankiru\Api\Rpc\Routing\Exception\MethodNotFoundException;
use Bankiru\Api\Rpc\Routing\MethodMatcher;
final class {$options['class']} implements MethodMatcher
/** {@inheritdoc} */
public function match(\$method)
\$routes = [
CONTENT;
foreach ($collection->all() as $name => $method) {
$ret = var_export(AttributesHelper::getAttributes($method, $name), true);
$content .= PHP_EOL .
'{$method->getMethod()}' => {$ret},
}
$content .=
];
if (array_key_exists(\$method, \$routes)) {
return \$routes[\$method];
throw new MethodNotFoundException(\$method);
return $content;