/** * @param Raml\Resource $resource * @param string $httpMethod * * @throw Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException * * @return Raml\Method */ protected function getMethodFromResource(Resource $resource, $httpMethod) { try { $httpMethod = strtoupper($httpMethod); $method = $resource->getMethod($httpMethod); } catch (\Exception $e) { $methods = []; foreach ($resource->getMethods() as $method) { $methods[] = $method->getType(); } if ($httpMethod !== 'OPTIONS') { throw new MethodNotAllowedHttpException($methods, $e->getMessage()); } } return $method; }