src/Model/ObjectFactory.php
public static function init(JSONObject $json)
	{
		$object = NULL;
		
		if(!$json->has("@type"))
			throw new ModelFormatException("Not a valid object");
		try
		{
			switch(strtolower($json->get("@type")))
			{
				case "comment":
					$object = CommentObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "like":
					$object = LikeObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "image":
					$object = ImageObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "profile":
					$object = ProfileObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation":
					$object = ConversationObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation-status":
					$object = ConversationStatusObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation-message":
					$object = ConversationMessageObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation-message-status":
					$object = ConversationMessageStatusObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "accesscontrolgroup":
					$object = AccessControlGroupObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "accesscontrolrule":
					$object = AccessControlRuleObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "link":
					$object = LinkObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "link-request":
					$object = LinkRequesObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "link-response":
					$object = LinkResponseObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "response":
					$object = ResponseObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "search-query":
					$object = SearchQueryObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "search-result":
					$object = SearchResultObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "search-result-collection":
					$object = SearchResultCollectionObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				//case "signature":
					//$object = SignaObjectBuilder::buildFromJSON($json->__toString());
				//break;
				
				// feature
				// migration
				
				case "activity":
					$object = StreamItemObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "tag":
					$object = TagObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				default:
					throw new ModelFormatException("Not a valid object type");
				break;
			}
		}
		catch(Exception $e)
		{
			throw new ModelFormatException("Could not init object for " . strtolower($json->get("@type")) . ": " . $e->getMessage());
		}
		
		return $object;
	}
public static function init(JSONObject $json)
	{
		$object = NULL;
		
		if(!$json->has("@type"))
			throw new ModelFormatException("Not a valid object");
		try
		{
			switch(strtolower($json->get("@type")))
			{
				case "comment":
					$object = CommentObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "like":
					$object = LikeObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "image":
					$object = ImageObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "profile":
					$object = ProfileObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation":
					$object = ConversationObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation-status":
					$object = ConversationStatusObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation-message":
					$object = ConversationMessageObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "conversation-message-status":
					$object = ConversationMessageStatusObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "accesscontrolgroup":
					$object = AccessControlGroupObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "accesscontrolrule":
					$object = AccessControlRuleObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "link":
					$object = LinkObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "link-request":
					$object = LinkRequesObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "link-response":
					$object = LinkResponseObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "response":
					$object = ResponseObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "search-query":
					$object = SearchQueryObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "search-result":
					$object = SearchResultObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "search-result-collection":
					$object = SearchResultCollectionObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				//case "signature":
					//$object = SignaObjectBuilder::buildFromJSON($json->__toString());
				//break;
				
				// feature
				// migration
				
				case "activity":
					$object = StreamItemObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				case "tag":
					$object = TagObjectBuilder::buildFromJSON($json->__toString());
				break;
				
				default:
					throw new ModelFormatException("Not a valid object type");
				break;
			}
		}
		catch(Exception $e)
		{
			throw new ModelFormatException("Could not init object for " . strtolower($json->get("@type")) . ": " . $e->getMessage());
		}
		
		return $object;
	}
public static function init ( JSONObject $ json ) { $ object = NULL ; if ( ! $ json -> has ( "@type" ) ) throw new ModelFormatException ( "Not a valid object" ) ; try { switch ( strtolower ( $ json -> get ( "@type" ) ) ) { case "comment" : $ object = CommentObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "like" : $ object = LikeObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "image" : $ object = ImageObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "profile" : $ object = ProfileObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation" : $ object = ConversationObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation-status" : $ object = ConversationStatusObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation-message" : $ object = ConversationMessageObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation-message-status" : $ object = ConversationMessageStatusObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "accesscontrolgroup" : $ object = AccessControlGroupObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "accesscontrolrule" : $ object = AccessControlRuleObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "link" : $ object = LinkObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "link-request" : $ object = LinkRequesObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "link-response" : $ object = LinkResponseObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "response" : $ object = ResponseObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "search-query" : $ object = SearchQueryObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "search-result" : $ object = SearchResultObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "search-result-collection" : $ object = SearchResultCollectionObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; //case "signature": //$object = SignaObjectBuilder::buildFromJSON($json->__toString()); //break; // feature // migration case "activity" : $ object = StreamItemObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "tag" : $ object = TagObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; default : throw new ModelFormatException ( "Not a valid object type" ) ; break ; } } catch ( Exception $ e ) { throw new ModelFormatException ( "Could not init object for " . strtolower ( $ json -> get ( "@type" ) ) . ": " . $ e -> getMessage ( ) ) ; } return $ object ; }
Parses the JSONObject and creates a matching Sonic object

@param JSONObbject $json The JSONObject to parse
@return BasicObject
@throws ModelFormatException on malformed object content
Parses the JSONObject and creates a matching Sonic object