Completed
Push — master ( 49f631...00219d )
by Frank
03:48
created

Route   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 42
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getPath() 0 4 1
A getMethod() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the package neoblack/free-at-home-api.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE file that was distributed with this source code.
9
 */
10
11
namespace NeoBlack\FreeAtHomeApi\Entity;
12
13
use NeoBlack\FreeAtHomeApi\Exception\MethodNotAllowedException;
14
15
class Route
16
{
17
    public const METHOD_GET = 'GET';
18
    public const METHOD_POST = 'POST';
19
    public const METHOD_PUT = 'PUT';
20
    public const METHOD_DELETE = 'DELETE';
21
22
    private $allowedMethods = [
23
        self::METHOD_GET,
24
        self::METHOD_POST,
25
        self::METHOD_PUT,
26
        self::METHOD_DELETE
27
    ];
28
29
    protected $path;
30
    protected $method;
31
32 10
    public function __construct(string $path, string $method)
33
    {
34 10
        if (!\in_array($method, $this->allowedMethods, true)) {
35 5
            throw new MethodNotAllowedException('The method "' . $method . '" is not allowed', 1536352833);
36
        }
37 5
        $this->path = $path;
38 5
        $this->method = $method;
39 5
    }
40
41
    /**
42
     * @return string
43
     */
44 5
    public function getPath(): string
45
    {
46 5
        return $this->path;
47
    }
48
49
    /**
50
     * @return string
51
     */
52 5
    public function getMethod(): string
53
    {
54 5
        return $this->method;
55
    }
56
}
57