Passed
Push — master ( abf367...1c21c5 )
by Pieter
02:19
created

ResponseEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 10
c 2
b 0
f 1
dl 0
loc 58
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setResponse() 0 3 1
A getResponse() 0 3 1
A __construct() 0 4 1
A getResource() 0 3 1
A getAcceptHeader() 0 3 1
1
<?php
2
3
namespace W2w\Lib\Apie\Events;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
/**
8
 * Event mediator for normalizing a value from a hydrated resource to a PSR response.
9
 */
10
class ResponseEvent
11
{
12
    private $resource;
13
14
    /**
15
     * @var string
16
     */
17
    private $acceptHeader;
18
19
    /**
20
     * @var ResponseInterface|null
21
     */
22
    private $response;
23
24
    /**
25
     * @param mixed $resource
26
     * @param string $acceptHeader
27
     */
28
    public function __construct($resource, string $acceptHeader)
29
    {
30
        $this->resource = $resource;
31
        $this->acceptHeader = $acceptHeader;
32
    }
33
34
    /**
35
     * @return ResponseInterface
36
     */
37
    public function getResponse(): ?ResponseInterface
38
    {
39
        return $this->response;
40
    }
41
42
    /**
43
     * @param ResponseInterface $response
44
     */
45
    public function setResponse(ResponseInterface $response)
46
    {
47
        $this->response = $response;
48
    }
49
50
    /**
51
     * Get the accept header.
52
     *
53
     * @return string
54
     */
55
    public function getAcceptHeader(): string
56
    {
57
        return $this->acceptHeader;
58
    }
59
60
    /**
61
     * Get the resource.
62
     *
63
     * @return mixed
64
     */
65
    public function getResource()
66
    {
67
        return $this->resource;
68
    }
69
}
70