Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4.0072 |
Changes | 0 |
1 | <?php |
||
22 | 22 | public function decode(ReadableMessage $message) |
|
23 | { |
||
24 | 22 | $bodyContent = $message->getRawBody(); |
|
25 | 22 | $contentType = $message->getContentType(); |
|
26 | |||
27 | switch($contentType) |
||
28 | { |
||
29 | 21 | case ContentType::TEXT: |
|
30 | 6 | return new Text($bodyContent); |
|
31 | |||
32 | 15 | case ContentType::JSON: |
|
33 | 1 | $body = new Json(); |
|
34 | 1 | $body->changeContentWithJson($bodyContent); |
|
35 | |||
36 | 1 | return $body; |
|
37 | |||
38 | 14 | case ContentType::BINARY: |
|
39 | return new Binary($bodyContent); |
||
40 | } |
||
41 | |||
42 | 14 | $this->logger->warning(__CLASS__ . ": unknown content-type, use empty body"); |
|
43 | |||
44 | 14 | return new NullBody(); |
|
45 | } |
||
46 | } |
||
47 |