46 lines
1.7 KiB
PHP
46 lines
1.7 KiB
PHP
<?php
|
|
|
|
$routes = [];
|
|
|
|
$methods = ['GET', 'POST', 'PUT', 'DELETE'];
|
|
$apis = ['blog', 'github', 'dragonknight', 'ecchi', 'hentai', 'harem', 'isekai', 'mecha', 'romance', 'shoujo', 'shounen', 'slice-of-life', 'supernatural', 'yuri'];
|
|
$params = ['id', 'slug', 'page', 'extra', 'foo', 'string', 'number', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'];
|
|
$endpoint = ['edit', 'create', 'delete', 'view', 'change', 'modify', 'generate', 'lift', 'lower', 'raise', 'drop', 'pick', 'choose', 'select', 'deselect', 'unselect', 'reselect', 'pick', 'unpick', 'repick', 'reselect', 'reunpick', 'rechoose', 'reselect'];
|
|
$midpoint = ['do', 'cause', 'effect', 'affect', 'impact', 'influence', 'change', 'modify', 'transform', 'alter', 'shift', 'adjust', 'adapt', 'convert', 'translate'];
|
|
|
|
// Generate routes
|
|
for ($i = 0; $i < 1000; $i++) {
|
|
$routes[] = makeRoute();
|
|
// write the routes array to a file
|
|
file_put_contents('routes/big.txt', implode("\n", $routes));
|
|
}
|
|
|
|
function makeRoute(): string
|
|
{
|
|
global $methods, $apis, $params, $endpoint, $midpoint;
|
|
|
|
$method = $methods[array_rand($methods)];
|
|
$api = $apis[array_rand($apis)];
|
|
$route = "/$api";
|
|
$length = rand(1, 8);
|
|
$options = ['params', 'endpoint', 'midpoint'];
|
|
for ($i = 0; $i < $length; $i++) {
|
|
$option = $options[array_rand($options)];
|
|
switch ($option) {
|
|
case 'params':
|
|
$param = $params[array_rand($params)];
|
|
$route .= "/:$param";
|
|
break;
|
|
case 'endpoint':
|
|
$end = $endpoint[array_rand($endpoint)];
|
|
$route .= "/$end";
|
|
break;
|
|
case 'midpoint':
|
|
$mid = $midpoint[array_rand($midpoint)];
|
|
$route .= "/$mid";
|
|
break;
|
|
}
|
|
}
|
|
return $method . ' ' . $route;
|
|
}
|