本文整理汇总了PHP中Node::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::setName方法的具体用法?PHP Node::setName怎么用?PHP Node::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::setName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createElement
function createElement($name)
{
$node = new Node();
$node->setName($name);
$node->setType(ELEMENT);
return $node;
}
示例2: xmlToObject
/**
* Converts an XML string into an object struct.
*
* @param string $data The XML string
*
* @return esXml The parsed XML
*/
private function xmlToObject($data)
{
$root = new Node();
$root->setName('root');
$actualLevel = 1;
$actualNode = $root;
$stack = array();
$stack[1] = $root;
foreach ($this->parseIntoStruct($data) as $element) {
if ($element['type'] === 'close') {
continue;
}
$node = new Node();
$node->setName($element['tag']);
if (isset($element['attributes'])) {
$node->setAttributes($element['attributes']);
}
if (isset($element['value'])) {
$node->setValue($element['value']);
}
$level = $element['level'];
if ($level > $actualLevel) {
$stack[$level] = $actualNode;
}
$stack[$level]->addChild($node);
$actualNode = $node;
$actualLevel = $element['level'];
}
$children = $root->getChildren();
unset($root);
return $children[0]->setParent(null);
}
示例3: nameAccessors
public function nameAccessors()
{
$n = new Node('node');
$n->setName('name');
$this->assertEquals('name', $n->getName());
}
示例4: traverseTag
/**
* Read the next tag from the stream.
*
* @param resource $fPtr Stream pointer
* @param Node $node Tree array to write to
*
* @return bool
*/
private function traverseTag($fPtr, Node &$node)
{
if (feof($fPtr)) {
return false;
}
// Read type byte
$tagType = $this->dataHandler->getTAGByte($fPtr);
if ($tagType == Tag::TAG_END) {
return false;
} else {
$node->setType($tagType);
$tagName = $this->dataHandler->getTAGString($fPtr);
$node->setName($tagName);
$this->readType($fPtr, $tagType, $node);
return true;
}
}
示例5: testSetNameMethodException
/**
* @expectedException \InvalidArgumentException
*/
public function testSetNameMethodException()
{
$this->object->setName('foo');
$this->object->setName('baz');
}
示例6: __set
/**
* Adds a child to the current node.
*
* @param string $name
* @param Node $node
*/
public function __set($name, $node)
{
if ($node instanceof static) {
$this->addChild($node->setName($name));
}
}