/** * @param \stdClass $response * * @return OrderItemRelation */ public static function from_response(\stdClass $response) { $obj = new static(); $obj->order_item_id = absint($response->order_item_id); if (is_numeric($response->key)) { $obj->key = absint($response->key); } else { if ($response->key instanceof \stdClass) { $obj->key = Key::from_response($response->key); } else { assert(FALSE, 'unknown $response->key structure.'); } } if (is_numeric($response->domain)) { $obj->domain = absint($response->domain); } else { if ($response->domain instanceof \stdClass) { $obj->domain = Domain::from_response($response->domain); } else { if ($response->domain === NULL) { // It can be null. Ok, do nothing. $obj->domain = NULL; } else { assert(FALSE, 'unknown $response->domain structure.'); } } } $obj->user_id = absint($response->user_id); return $obj; }