MethodNotAllowedException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
4
namespace W2w\Lib\Apie\Exceptions;
5
6
use W2w\Lib\ApieObjectAccessNormalizer\Exceptions\ApieException;
7
use W2w\Lib\ApieObjectAccessNormalizer\Exceptions\LocalizationableException;
8
use W2w\Lib\ApieObjectAccessNormalizer\Exceptions\LocalizationInfo;
9
10
/**
11
 * Exception thrown when a wrong HTTP method is chosen.
12
 */
13
class MethodNotAllowedException extends ApieException implements LocalizationableException
14
{
15
    /**
16
     * @var string
17
     */
18
    private $method;
19
20
    public function __construct(string $method)
21
    {
22
        $this->method = $method;
23
        parent::__construct(405, "Resource has no " . $method . " support");
24
    }
25
26
    public function getI18n(): LocalizationInfo
27
    {
28
        return new LocalizationInfo(
29
            'general.method_not_allowed',
30
            [
31
                'method' => $this->method,
32
            ]
33
        );
34
    }
35
}
36