| Conditions | 5 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 3 |
| 1 | <?php |
||
| 27 | public static function factory($json) |
||
| 28 | { |
||
| 29 | $deserialized = json_decode($json); |
||
| 30 | |||
| 31 | if (!isset($deserialized->type) || !isset($deserialized->payload)) |
||
| 32 | throw new MalformedRequestException('Missing "type" or "payload"'); |
||
| 33 | |||
| 34 | $type = $deserialized->type; |
||
| 35 | $parameters = $deserialized->payload; |
||
| 36 | |||
| 37 | switch ($type) |
||
| 38 | { |
||
| 39 | case AbstractMessage::TYPE_POPULAR_CHANNELS_REQUEST: |
||
| 40 | return new PopularChannelsRequest($parameters); |
||
| 41 | case AbstractMessage::TYPE_MOST_ACTIVE_WATCHERS_REQUEST: |
||
| 42 | return new MostActiveWatchersRequest($parameters); |
||
| 43 | default: |
||
| 44 | throw new UnknownRequestException('Unknown message "' . $type . '"'); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 58 |