Completed
Push — master ( a5eb40...fc96a9 )
by Sebastian
02:23
created

DeleteRequest::getParameter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace Kartenmacherei\RestFramework\Request;
3
4
use Kartenmacherei\RestFramework\Request\Body\Body;
5
use Kartenmacherei\RestFramework\Request\Header\HeaderCollection;
6
use Kartenmacherei\RestFramework\Request\Method\DeleteRequestMethod;
7
use Kartenmacherei\RestFramework\Request\Method\RequestMethod;
8
9
class DeleteRequest extends Request
10
{
11
    /**
12
     * @var array
13
     */
14
    private $parameters;
15
16
    /**
17
     * @var Body
18
     */
19
    private $body;
20
21
    /**
22
     * @param Uri $uri
23
     * @param HeaderCollection $headers
24
     * @param array $parameters
25
     * @param Body $body
26
     */
27
    public function __construct(Uri $uri, HeaderCollection $headers, array $parameters, Body $body)
28
    {
29
        parent::__construct($uri, $headers);
30
        $this->parameters = $parameters;
31
        $this->body = $body;
32
    }
33
34
    /**
35
     * @param $name
36
     * @return bool
37
     */
38
    public function hasParameter($name): bool
39
    {
40
        return array_key_exists($name, $this->parameters);
41
    }
42
43
    /**
44
     * @param $name
45
     * @return mixed
46
     * @throws RequestParameterException
47
     */
48 View Code Duplication
    public function getParameter($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        if (!$this->hasParameter($name)) {
51
            throw new RequestParameterException(sprintf('Parameter %s not found'));
52
        }
53
        return $this->parameters[$name];
54
    }
55
56
    /**
57
     * @return Body
58
     */
59
    public function getBody(): Body
60
    {
61
        return $this->body;
62
    }
63
64
    /**
65
     * @return RequestMethod
66
     */
67
    public function getMethod(): RequestMethod
68
    {
69
        return new DeleteRequestMethod();
70
    }
71
}
72