private function getHttpMethodAndResourcesFromMethod(\ReflectionMethod $method, $resource)
    {
        // if method doesn't match regex - skip
        if (!preg_match('/([a-z][_a-z0-9]+)(.*)Action/', $method->getName(), $matches)) {
            return false;
        }

        $httpMethod = strtolower($matches[1]);
        $resources = preg_split(
            '/([A-Z][^A-Z]*)/', $matches[2], -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
        );
        $isCollection = false;
        $isInflectable = true;

        if (0 === strpos($httpMethod, self::COLLECTION_ROUTE_PREFIX)
            && in_array(substr($httpMethod, 1), $this->availableHTTPMethods)
        ) {
            $isCollection = true;
            $httpMethod = substr($httpMethod, 1);
        } elseif ('options' === $httpMethod) {
            $isCollection = true;
        }

        if ($isCollection && !empty($resource)) {
            $resourcePluralized = $this->generateResourceName(end($resource));
            $isInflectable = ($resourcePluralized != $resource[count($resource) - 1]);
            $resource[count($resource) - 1] = $resourcePluralized;
        }

        $resources = array_merge($resource, $resources);

        return [$httpMethod, $resources, $isCollection, $isInflectable];
    }
private function getHttpMethodAndResourcesFromMethod(\ReflectionMethod $method, $resource)
    {
        // if method doesn't match regex - skip
        if (!preg_match('/([a-z][_a-z0-9]+)(.*)Action/', $method->getName(), $matches)) {
            return false;
        }

        $httpMethod = strtolower($matches[1]);
        $resources = preg_split(
            '/([A-Z][^A-Z]*)/', $matches[2], -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
        );
        $isCollection = false;
        $isInflectable = true;

        if (0 === strpos($httpMethod, self::COLLECTION_ROUTE_PREFIX)
            && in_array(substr($httpMethod, 1), $this->availableHTTPMethods)
        ) {
            $isCollection = true;
            $httpMethod = substr($httpMethod, 1);
        } elseif ('options' === $httpMethod) {
            $isCollection = true;
        }

        if ($isCollection && !empty($resource)) {
            $resourcePluralized = $this->generateResourceName(end($resource));
            $isInflectable = ($resourcePluralized != $resource[count($resource) - 1]);
            $resource[count($resource) - 1] = $resourcePluralized;
        }

        $resources = array_merge($resource, $resources);

        return [$httpMethod, $resources, $isCollection, $isInflectable];
    }
private function getHttpMethodAndResourcesFromMethod ( \ ReflectionMethod $ method , $ resource ) { // if method doesn't match regex - skip if ( ! preg_match ( '/([a-z][_a-z0-9]+)(.*)Action/' , $ method -> getName ( ) , $ matches ) ) { return false ; } $ httpMethod = strtolower ( $ matches [ 1 ] ) ; $ resources = preg_split ( '/([A-Z][^A-Z]*)/' , $ matches [ 2 ] , - 1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) ; $ isCollection = false ; $ isInflectable = true ; if ( 0 === strpos ( $ httpMethod , self :: COLLECTION_ROUTE_PREFIX ) && in_array ( substr ( $ httpMethod , 1 ) , $ this -> availableHTTPMethods ) ) { $ isCollection = true ; $ httpMethod = substr ( $ httpMethod , 1 ) ; } elseif ( 'options' === $ httpMethod ) { $ isCollection = true ; } if ( $ isCollection && ! empty ( $ resource ) ) { $ resourcePluralized = $ this -> generateResourceName ( end ( $ resource ) ) ; $ isInflectable = ( $ resourcePluralized != $ resource [ count ( $ resource ) - 1 ] ) ; $ resource [ count ( $ resource ) - 1 ] = $ resourcePluralized ; } $ resources = array_merge ( $ resource , $ resources ) ; return [ $ httpMethod , $ resources , $ isCollection , $ isInflectable ] ; }
Returns HTTP method and resources list from method signature.

@param \ReflectionMethod $method
@param string[]          $resource

@return bool|array
Returns HTTP method and resources list from method signature .