Passed
Pull Request — master (#56)
by Anatoly
04:25
created

MethodNotAllowedException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedMethods() 0 3 1
A getJoinedAllowedMethods() 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 allowed methods
27
     *
28
     * @return string[]
29
     */
30 5
    public function getAllowedMethods() : array
31
    {
32 5
        return $this->fromContext('allowed', []);
33
    }
34
35
    /**
36
     * Gets joined allowed methods
37
     *
38
     * @return string
39
     */
40 1
    public function getJoinedAllowedMethods() : string
41
    {
42 1
        return implode(',', $this->getAllowedMethods());
43
    }
44
}
45