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

MethodNotAllowedException::getAllowedMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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