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