GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MethodNotMatched   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 15
c 0
b 0
f 0
dl 0
loc 69
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedMethods() 0 3 1
A __construct() 0 10 2
A getFailedMethod() 0 3 1
A generateMessage() 0 9 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Meraki\Route\Exception;
5
6
use RuntimeException;
7
use Meraki\Route\Exception as RouteException;
8
use LogicException;
9
10
/**
11
 * Exception used when the method of a route could not be matched to the request.
12
 *
13
 * @author Nathan Bishop <[email protected]> (https://nathanbishop.name)
14
 * @copyright 2019 Nathan Bishop
15
 * @license The MIT license.
16
 */
17
final class MethodNotMatched extends RuntimeException implements RouteException
18
{
19
    /**
20
     *
21
     */
22
    public const EQUIVALENT_STATUS_CODE = 405;
23
24
    /**
25
     * @var string [$failedMethod description]
26
     */
27
    private $failedMethod;
28
29
    /**
30
     * @var string[] [$allowedMethods description]
31
     */
32
    private $allowedMethods;
33
34
    /**
35
     * [__construct description]
36
     *
37
     * @param string $failedMethod [description]
38
     * @param string[] $allowedMethods [description]
39
     */
40
    public function __construct(string $failedMethod, array $allowedMethods = [])
41
    {
42
        $this->failedMethod = strtoupper($failedMethod);
43
        $this->allowedMethods = array_map('strtoupper', $allowedMethods);
44
45
        if (in_array($this->failedMethod, $this->allowedMethods)) {
46
            throw new LogicException('The method that failed the match should not be in the allowed methods.');
47
        }
48
49
        parent::__construct($this->generateMessage(), self::EQUIVALENT_STATUS_CODE);
50
    }
51
52
    /**
53
     * [getFailedMethod description]
54
     *
55
     * @return string [description]
56
     */
57
    public function getFailedMethod(): string
58
    {
59
        return $this->failedMethod;
60
    }
61
62
    /**
63
     * [getAllowedMethods description]
64
     *
65
     * @return string[] [description]
66
     */
67
    public function getAllowedMethods(): array
68
    {
69
        return $this->allowedMethods;
70
    }
71
72
    /**
73
     * [generateMessage description]
74
     *
75
     * @return strings [description]
0 ignored issues
show
Bug introduced by
The type Meraki\Route\Exception\strings was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
76
     */
77
    private function generateMessage(): string
78
    {
79
        $message = sprintf('The "%s" method could not be matched.', $this->failedMethod);
80
81
        if (!empty($this->allowedMethods)) {
82
            $message .= sprintf(' Try one of the following: %s', implode(', ', $this->allowedMethods));
83
        }
84
85
        return $message;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $message returns the type string which is incompatible with the documented return type Meraki\Route\Exception\strings.
Loading history...
86
    }
87
}
88