Test Failed
Pull Request — master (#74)
by Anatoly
05:22 queued 02:58
created

MethodNotAllowedException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 3
c 2
b 0
f 0
dl 0
loc 33
ccs 4
cts 4
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedMethods() 0 3 1
A getJoinedAllowedMethods() 0 3 1
A getMethod() 0 3 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Fenric <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Fenric
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
namespace Sunrise\Http\Router\Exception;
13
14
/**
15
 * Import functions
16
 */
17
use function implode;
18
19
/**
20
 * MethodNotAllowedException
21
 */
22
class MethodNotAllowedException extends Exception
23
{
24
25
    /**
26
     * Gets a method
27
     *
28
     * @return string
29
     *
30 5
     * @since 2.9.0
31
     */
32 5
    public function getMethod() : string
33
    {
34
        return $this->fromContext('method', '');
35
    }
36
37
    /**
38
     * Gets allowed methods
39
     *
40 1
     * @return string[]
41
     */
42 1
    public function getAllowedMethods() : array
43
    {
44
        return $this->fromContext('allowed', []);
45
    }
46
47
    /**
48
     * Gets joined allowed methods
49
     *
50
     * @return string
51
     */
52
    public function getJoinedAllowedMethods() : string
53
    {
54
        return implode(',', $this->getAllowedMethods());
55
    }
56
}
57