summaryrefslogtreecommitdiffstats
path: root/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php
blob: 4e40b6adacaf709d5b694bb0a1058908a80d1573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/* Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */

namespace Icinga\Exception\Http;

/**
 * Exception thrown if the HTTP method is not allowed
 */
class HttpMethodNotAllowedException extends BaseHttpException
{
    protected $statusCode = 405;

    /**
     * Get the allowed HTTP methods
     *
     * @return string
     */
    public function getAllowedMethods()
    {
        $headers = $this->getHeaders();
        return isset($headers['Allow']) ? $headers['Allow'] : null;
    }

    /**
     * Set the allowed HTTP methods
     *
     * @param   string $allowedMethods
     *
     * @return  $this
     */
    public function setAllowedMethods($allowedMethods)
    {
        $this->setHeader('Allow', (string) $allowedMethods);
        return $this;
    }
}