Total Complexity | 9 |
Total Lines | 86 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class ProcessorResponse implements ResponseInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $data; |
||
15 | |||
16 | /** |
||
17 | * @var Request |
||
18 | */ |
||
19 | protected $request; |
||
20 | |||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | protected $status; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | protected $isHttpReady = false; |
||
30 | |||
31 | public function __construct(Request $request, array $data, $httpReady = false, $status = 200) |
||
32 | { |
||
33 | $this->request = $request; |
||
34 | $this->data = $data; |
||
35 | $this->isHttpReady = $httpReady; |
||
36 | $this->status = $status; |
||
37 | } |
||
38 | |||
39 | public function toHttpResponse() |
||
40 | { |
||
41 | if (!$this->isHttpReady) { |
||
42 | throw new ProcessingException('Response is not ready yet to be set as http'); |
||
43 | } |
||
44 | return $this->createResponse($this->request); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return array |
||
49 | */ |
||
50 | public function getData() |
||
51 | { |
||
52 | return $this->data; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return int |
||
57 | */ |
||
58 | public function getStatus() |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param Request $request |
||
65 | * |
||
66 | * @return Response |
||
67 | */ |
||
68 | private function createResponse(Request $request) |
||
76 | ); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @param string $format |
||
81 | * @return string |
||
82 | */ |
||
83 | private function getContentTypeByFormat($format) |
||
95 | } |
||
96 | } |
||
97 | } |
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.