F2m2\Apidocs\Commands\ApiDocsGenerator::getEndpointMethods PHP Method

getEndpointMethods() protected method

Returns functions for the endpoints
protected getEndpointMethods ( $endpoints ) : array
$endpoints
return array
    protected function getEndpointMethods($endpoints)
    {
        foreach ($this->routes as $route) {
            $array = explode("@", $route['action']);
            $class = $array[0];
            if ($class == "Closure") {
                continue;
            }
            $methodName = count($array) > 1 ? $array[1] : '';
            $endpointName = str_replace('Controller', '', $class);
            $reflector = new ReflectionClass($class);
            $docBlock = new DocBlock($reflector->getMethod($methodName));
            $controllerDocBlock = new DocBlock($reflector);
            $endpointNameCamelCase = $this->convertToSnakeCase($endpointName);
            $endpointNameCamelCasePlural = $this->convertToSnakeCase($endpointName) . 's';
            $route['uri'] = str_replace('{' . strtolower($endpointName) . '}', '{id}', $route['uri']);
            $route['uri'] = str_replace('{' . strtolower($endpointName) . 's}', '{id}', $route['uri']);
            $route['uri'] = str_replace('{' . strtolower($endpointNameCamelCase) . '}', '{id}', $route['uri']);
            $route['uri'] = str_replace('{' . strtolower($endpointNameCamelCasePlural) . '}', '{id}', $route['uri']);
            $route['function'] = $methodName;
            $route['docBlock'] = $docBlock;
            $route['controllerDocBlock'] = $controllerDocBlock;
            array_push($endpoints["{$endpointName}"]['methods'], $route);
        }
        return $endpoints;
    }