Skip to content

Commit

Permalink
Change coding style to PSR-2
Browse files Browse the repository at this point in the history
This closes #1.
  • Loading branch information
lanthaler committed Dec 13, 2012
1 parent 60e5c5a commit 8d0013a
Show file tree
Hide file tree
Showing 21 changed files with 1,944 additions and 2,555 deletions.
42 changes: 15 additions & 27 deletions Document.php
Expand Up @@ -49,7 +49,6 @@ class Document
*/
private $blankNodeCounter = 0;


/**
* Parses a JSON-LD document and returns it as a {@link Document}.
*
Expand All @@ -70,7 +69,7 @@ class Document
* - <em>base</em> The base IRI of the input document.
*
* @param string|array|object $document The JSON-LD document to process.
* @param null|array|object $options Options to configure the processing.
* @param null|array|object $options Options to configure the processing.
*
* @return Document The parsed JSON-LD document.
*
Expand Down Expand Up @@ -102,20 +101,17 @@ public function __construct($baseIri = null)
* that node will be returned instead of creating a new one.
*
* @param null|string $id The ID of the node.
*
* @return Node The newly created node.
*/
public function createNode($id = null)
{
if (!is_string($id) || ('_:' === substr($id, 0, 2)))
{
if (!is_string($id) || ('_:' === substr($id, 0, 2))) {
$id = $this->createBlankNodeId();
$abs_id = $id;
}
else
{
} else {
$id = (string) $this->baseIri->resolve($id);
if (isset($this->nodes[$id]))
{
if (isset($this->nodes[$id])) {
return $this->nodes[$id];
}
}
Expand All @@ -133,15 +129,13 @@ public function createNode($id = null)
*/
public function remove(Node $node)
{
if ($node->getDocument() === $this)
{
if ($node->getDocument() === $this) {
$node->removeFromDocument();
}

$id = $node->getId();

if (!$node->isBlankNode())
{
if (!$node->isBlankNode()) {
$id = (string) $this->baseIri->resolve($id);
}

Expand All @@ -168,8 +162,7 @@ public function getNodes()
*/
public function getNode($id)
{
if (!((strlen($id) >= 2) && ('_:' === substr($id, 0, 2))))
{
if (!((strlen($id) >= 2) && ('_:' === substr($id, 0, 2)))) {
$id = (string) $this->baseIri->resolve($id);
}

Expand All @@ -188,10 +181,8 @@ public function getNode($id)
*/
public function getNodesByType($type)
{
if (is_string($type))
{
if (null === ($type = $this->getNode($type)))
{
if (is_string($type)) {
if (null === ($type = $this->getNode($type))) {
return array();
}
}
Expand All @@ -207,27 +198,24 @@ public function getNodesByType($type)
* will always return false except a node instance
* which is part of the document will be passed
* instead of a string.
*
* @return bool Returns true if the document contains a node with the
* specified ID; false otherwise.
*/
public function contains($id)
{
$node = $id;

if ($node instanceof Node)
{
if ($node instanceof Node) {
$id = $node->getId();
}

if ((null === $id) || !is_string($id))
{
if ((null === $id) || !is_string($id)) {
return false;
}

if ((strlen($id) >= 2) && ('_:' === substr($id, 0, 2)))
{
if (isset($this->nodes[$id]) && ($node === $this->nodes[$id]))
{
if ((strlen($id) >= 2) && ('_:' === substr($id, 0, 2))) {
if (isset($this->nodes[$id]) && ($node === $this->nodes[$id])) {
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions Exception/InvalidQuadException.php
Expand Up @@ -11,7 +11,6 @@

use ML\JsonLD\Quad;


/**
* Exception that is thrown when an invalid quad is detected.
*
Expand All @@ -26,7 +25,6 @@ class InvalidQuadException extends \RuntimeException
*/
private $quad;


/**
* Constructor.
*
Expand Down
1 change: 0 additions & 1 deletion Exception/ParseException.php
Expand Up @@ -30,7 +30,6 @@ class ParseException extends \RuntimeException
*/
private $rawMessage;


/**
* Constructor.
*
Expand Down
2 changes: 0 additions & 2 deletions Exception/ProcessException.php
Expand Up @@ -11,7 +11,6 @@

use ML\JsonLD\JsonLD;


/**
* Exception class thrown when an error occurs during processing.
*
Expand Down Expand Up @@ -40,7 +39,6 @@ class ProcessException extends \RuntimeException
*/
private $rawMessage;


/**
* Constructor.
*
Expand Down
2 changes: 0 additions & 2 deletions Exception/SyntaxException.php
Expand Up @@ -11,7 +11,6 @@

use ML\JsonLD\JsonLD;


/**
* Exception class thrown when a JSON-LD syntax error is detected.
*
Expand Down Expand Up @@ -40,7 +39,6 @@ class SyntaxException extends \RuntimeException
*/
private $rawMessage;


/**
* Constructor.
*
Expand Down

0 comments on commit 8d0013a

Please sign in to comment.