Skip to content

Commit

Permalink
Add more documentation for the Attribute node.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 28, 2019
1 parent 6215ceb commit 5ba5f85
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Exporter/Ascii.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function export(NodeInterface $node): string
protected function getNodeRepresentation(NodeInterface $node): string
{
if ($node instanceof ValueNodeInterface) {
return $node->getValue();
return (string) $node->getValue();
}

return \sha1(\spl_object_hash($node));
Expand Down
2 changes: 1 addition & 1 deletion src/Node/AttributeNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function getAttribute($key)
public function getAttribute(string $key)
{
return $this->getAttributes()[$key] ?? null;
}
Expand Down
30 changes: 25 additions & 5 deletions src/Node/AttributeNodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,42 @@
interface AttributeNodeInterface extends NaryNodeInterface
{
/**
* {@inheritdoc}
* Get an attribute.
*
* @return mixed
* The value of the attribute.
*/
public function getAttribute($key);
public function getAttribute(string $key);

/**
* {@inheritdoc}
* Get the attributes.
*
* @return \Traversable
* The attributes.
*/
public function getAttributes(): \Traversable;

/**
* {@inheritdoc}
* Set an attribute.
*
* @param string $key
* The attribute key.
* @param mixed $value
* The attribute value.
*
* @return \drupol\phptree\Node\AttributeNodeInterface
* The node.
*/
public function setAttribute(string $key, $value): AttributeNodeInterface;

/**
* {@inheritdoc}
* Set the attributes.
*
* @param \Traversable $attributes
* The attributes.
*
* @return \drupol\phptree\Node\AttributeNodeInterface
* The node.
*/
public function setAttributes(\Traversable $attributes): AttributeNodeInterface;
}

0 comments on commit 5ba5f85

Please sign in to comment.