Passed
Push — master ( a1e05c...a3afcf )
by Divine Niiquaye
02:24
created

MethodNotAllowedException::getAllowedMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Flight Routing.
7
 *
8
 * PHP version 7.1 and above required
9
 *
10
 * @author    Divine Niiquaye Ibok <[email protected]>
11
 * @copyright 2019 Biurad Group (https://biurad.com/)
12
 * @license   https://opensource.org/licenses/BSD-3-Clause License
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 */
17
18
namespace Flight\Routing\Exceptions;
19
20
use Flight\Routing\Interfaces\ExceptionInterface;
21
use RuntimeException;
22
23
/**
24
 * HTTP 405 exception.
25
 */
26
class MethodNotAllowedException extends RuntimeException implements ExceptionInterface
27
{
28
    /** @var string[] */
29
    private $methods;
30
31
    /**
32
     * @param string[] $methods
33
     * @param string   $path
34
     * @param string   $method
35
     */
36 2
    public function __construct(array $methods, string $path, string $method)
37
    {
38 2
        $this->methods = $methods;
39 2
        $message       = 'Unfortunately current uri "%s" is not allowed on [%s] request methods, "%s" is invalid';
40
41 2
        parent::__construct(\sprintf($message, $path, \implode(',', $methods), $method), 405);
42 2
    }
43
44
    /**
45
     * Gets allowed methods
46
     *
47
     * @return string[]
48
     */
49 2
    public function getAllowedMethods(): array
50
    {
51 2
        return $this->methods;
52
    }
53
}
54