1<?php 2 3namespace Sabre\DAV\Exception; 4 5use Sabre\DAV; 6 7/** 8 * MethodNotAllowed 9 * 10 * The 405 is thrown when a client tried to create a directory on an already existing directory 11 * 12 * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 13 * @author Evert Pot (http://evertpot.com/) 14 * @license http://sabre.io/license/ Modified BSD License 15 */ 16class MethodNotAllowed extends DAV\Exception { 17 18 /** 19 * Returns the HTTP statuscode for this exception 20 * 21 * @return int 22 */ 23 function getHTTPCode() { 24 25 return 405; 26 27 } 28 29 /** 30 * This method allows the exception to return any extra HTTP response headers. 31 * 32 * The headers must be returned as an array. 33 * 34 * @param \Sabre\DAV\Server $server 35 * @return array 36 */ 37 function getHTTPHeaders(\Sabre\DAV\Server $server) { 38 39 $methods = $server->getAllowedMethods($server->getRequestUri()); 40 41 return [ 42 'Allow' => strtoupper(implode(', ', $methods)), 43 ]; 44 45 } 46 47} 48