| Conditions | 4 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 25 | public static function factory($json) |
||
| 26 | { |
||
| 27 | $deserialized = json_decode($json); |
||
| 28 | |||
| 29 | if (!isset($deserialized->type) || !isset($deserialized->payload)) |
||
| 30 | throw new MalformedRequestException('Missing "type" or "payload"'); |
||
| 31 | |||
| 32 | $type = $deserialized->type; |
||
| 33 | $parameters = $deserialized->payload; |
||
| 34 | |||
| 35 | switch ($type) |
||
| 36 | { |
||
| 37 | case AbstractMessage::TYPE_STATISTICS_POPULAR_CHANNELS: |
||
| 38 | return new StatisticsPopularChannelsMessage($type, $parameters); |
||
| 39 | default: |
||
| 40 | throw new UnknownRequestException('Unknown message "' . $type . '"'); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 54 |