Skip to content

Instantly share code, notes, and snippets.

@bdb1234
Created June 25, 2015 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdb1234/1dfbf1080bf332dbcf27 to your computer and use it in GitHub Desktop.
Save bdb1234/1dfbf1080bf332dbcf27 to your computer and use it in GitHub Desktop.
<?php
/**
* @return ApiNode|null
*/
public function createDataNode()
{
/** @var ApiDataNode */
$dataNode = new ApiDataNode();
if (!is_null($this->date)) {
$dataNode->setAttribute(API_NODE_ATTR::DATE, $this->date, ApiNode::TYPE_STRING);
}
/** @var ApiNode */
$nestedGroupNode = new ApiNode(API_NODE_V5::NESTED_GROUP);
$nestedGroupNode->setAttribute(API_NODE_ATTR::NESTED_BOOL, $this->nestedBool, ApiNode::TYPE_BOOL);
/** @var ApiNode */
$nestedEndpointObjectNode = new ApiNode(API_NODE_V5::NESTED_ENDPOINT_OBJECT);
/** @var ApiListNode */
$alphanumericList = new ApiListNode(API_NODE_V5::ALPHANUMERIC);
foreach ($this->alphanumericList as $alphanumericListSortKey => $alphanumericListItem) {
/** @var ApiNode */
$primitiveNode = new ApiNode(API_NODE_V5::ALPHANUMERIC);
$primitiveNode->setAttribute(API_NODE_ATTR::VALUE, $alphanumericListItem, ApiNode::TYPE_STRING);
$alphanumericList->addToList($primitiveNode, $alphanumericListSortKey);
}
$nestedEndpointObjectNode->addChildNode($alphanumericList->getApiNode());
$nestedEndpointObjectNode->setAttribute(API_NODE_ATTR::DOUBLE_NESTED_GUID, $this->doubleNestedGuid, ApiNode::TYPE_STRING);
$nestedGroupNode->addChildNode($nestedEndpointObjectNode);
$nestedGroupNode->setAttribute(API_NODE_ATTR::NESTED_INT, $this->nestedInt, ApiNode::TYPE_INT);
$nestedGroupNode->setAttribute(API_NODE_ATTR::NESTED_STRING, $this->nestedString, ApiNode::TYPE_STRING);
$nestedGroupNode->addChildNode($this->nestedThing->getApiNode());
$dataNode->addChildNode($nestedGroupNode);
$dataNode->addChildNode($this->subsetInfo);
$dataNode->addChildNode($this->testObject->getApiNode());
/** @var ApiListNode */
$testSubObjectList = new ApiListNode(API_NODE_V5::TEST_SUB_OBJECT);
foreach ($this->testSubObjectList as $testSubObjectListSortKey => $testSubObjectListItem) {
$testSubObjectList->addToList($testSubObjectListItem->getApiNode(), $testSubObjectListSortKey);
}
$dataNode->addChildNode($testSubObjectList->getApiNode());
return $dataNode;
}
/**
*
*/
private function validateParameters()
{
$intList = $this->validateParam(API_PARAM_V5::INT_LIST, false, API_PARAM_TYPE_V5::STRING);
if (is_null($intList)) {
$this->intList = array();
} else {
$this->intList = explode(',', $intList);
foreach ($this->intList as $index => $item) {
$this->intList[$index] = intval($item);
}
}
$this->paramDescribedInt = $this->validateParam(API_PARAM_V5::PARAM_DESCRIBED_INT, true, API_PARAM_TYPE_V5::INT);
$this->paramOptionalInt = $this->validateParam(API_PARAM_V5::PARAM_OPTIONAL_INT, false, API_PARAM_TYPE_V5::INT);
$paramPlusAlphanumericList = $this->validateParam(API_PARAM_V5::PARAM_PLUS_ALPHANUMERIC_LIST, true, API_PARAM_TYPE_V5::STRING);
$this->paramPlusAlphanumericList = explode(',', $paramPlusAlphanumericList);
$this->paramString = $this->validateParam(API_PARAM_V5::PARAM_STRING, true, API_PARAM_TYPE_V5::STRING);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment