本文整理汇总了PHP中Node::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getValue方法的具体用法?PHP Node::getValue怎么用?PHP Node::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::getValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: equals
/**
* @see \Saft\Node
*/
public function equals(Node $toCompare)
{
// Only compare, if given instance is a literal
if ($toCompare->isLiteral() && $this->getDatatype()->equals($toCompare->getDatatype())) {
return $this->getValue() === $toCompare->getValue() && $this->getLanguage() == $toCompare->getLanguage();
}
return false;
}
示例2: toArray
/**
* Returns an array representation of the given Node structure.
*
* @param Node $node
*
* @return array
*/
public function toArray(Node $node)
{
return array('name' => $node->getName(), 'value' => $node->getValue(), 'attributes' => $node->getAttributes(), 'children' => array_map(function (Node $child) {
return $this->toArray($child);
}, $node->getChildren()));
}
示例3: matches
/**
* A literal matches only another literal if its value, datatype and language are equal.
*
* @param Node $toMatch Node instance to apply the pattern on
* @return boolean true, if this pattern matches the node, false otherwise
* @todo check if that could be deleted
*/
public function matches(Node $toMatch)
{
if ($toMatch->isConcrete()) {
if ($toMatch instanceof Literal) {
return $this->getValue() === $toMatch->getValue() && $this->getDatatype() === $toMatch->getDatatype() && $this->getLanguage() === $toMatch->getLanguage();
}
return false;
} else {
throw new \Exception('The node to match has to be a concrete node');
}
}
示例4: writeType
/**
* Write an individual type to the stream.
*
* @param resource $fPtr Stream pointer
* @param int $tagType Type of tag to write
* @param Node $node Node containing value to write
*
* @return bool
*/
private function writeType($fPtr, $tagType, Node $node)
{
switch ($tagType) {
case Tag::TAG_BYTE:
// Signed byte (8 bit)
return $this->dataHandler->putTAGByte($fPtr, $node->getValue());
case Tag::TAG_SHORT:
// Signed short (16 bit, big endian)
return $this->dataHandler->putTAGShort($fPtr, $node->getValue());
case Tag::TAG_INT:
// Signed integer (32 bit, big endian)
return $this->dataHandler->putTAGInt($fPtr, $node->getValue());
case Tag::TAG_LONG:
// Signed long (64 bit, big endian)
return $this->dataHandler->putTAGLong($fPtr, $node->getValue());
case Tag::TAG_FLOAT:
// Floating point value (32 bit, big endian, IEEE 754-2008)
return $this->dataHandler->putTAGFloat($fPtr, $node->getValue());
case Tag::TAG_DOUBLE:
// Double value (64 bit, big endian, IEEE 754-2008)
return $this->dataHandler->putTAGDouble($fPtr, $node->getValue());
case Tag::TAG_BYTE_ARRAY:
// Byte array
return $this->dataHandler->putTAGByteArray($fPtr, $node->getValue());
case Tag::TAG_STRING:
// String
return $this->dataHandler->putTAGString($fPtr, $node->getValue());
case Tag::TAG_INT_ARRAY:
// Byte array
return $this->dataHandler->putTAGIntArray($fPtr, $node->getValue());
case Tag::TAG_LIST:
// List
if (!($this->dataHandler->putTAGByte($fPtr, $node->getPayloadType()) && $this->dataHandler->putTAGInt($fPtr, count($node->getChildren())))) {
return false;
}
foreach ($node->getChildren() as $childNode) {
if (!$this->writeType($fPtr, $node->getPayloadType(), $childNode)) {
return false;
}
}
return true;
case Tag::TAG_COMPOUND:
// Compound
foreach ($node->getChildren() as $childNode) {
if (!$this->writeTag($fPtr, $childNode)) {
return false;
}
}
if (!$this->writeType($fPtr, Tag::TAG_END, new Node())) {
return false;
}
return true;
case Tag::TAG_END:
// End tag
return is_int(fwrite($fPtr, ""));
}
}