Permalink
Browse files

Rely on __toString()

  • Loading branch information...
1 parent a2f51c8 commit f19a92ddab134c4ded27bff04ea0edde92561b77 @CloCkWeRX CloCkWeRX committed Mar 25, 2012
View
7 RDF.php
@@ -1,10 +1,4 @@
<?php
-
-/**
- * Include PEAR base class
- */
-require_once 'PEAR.php';
-
// ----------------------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------------------
@@ -197,7 +191,6 @@ function factory($class, &$param)
}
require_once 'RDF/Exception.php';
-require_once 'RDF/Object.php';
require_once 'RDF/Util.php';
require_once 'RDF/Literal.php';
require_once 'RDF/Resource.php';
View
4 RDF/BlankNode.php
@@ -75,7 +75,7 @@ function getLabel()
* @access public
* @return string
*/
- function toString()
+ function __toString()
{
return 'bNode("' . $this->uri . '")';
}
@@ -104,4 +104,4 @@ function equals ($that)
return false;
}
} // end: BlankNode
-?>
+?>
View
4 RDF/FindIterator.php
@@ -17,7 +17,7 @@
* @access public
*
*/
-class RDF_FindIterator extends RDF_Object
+class RDF_FindIterator
{
/**
* Reference to the Model_Memory
@@ -108,4 +108,4 @@ function current()
}
}
-?>
+?>
View
4 RDF/Literal.php
@@ -159,7 +159,7 @@ function equals ($that)
* @access public
* @return string
*/
- function toString()
+ function __toString()
{
$dump = 'Literal("' . $this->label . '"';
if ($this->lang != null) {
@@ -172,4 +172,4 @@ function toString()
return $dump;
}
} // end: Literal
-?>
+?>
View
4 RDF/Model.php
@@ -15,7 +15,7 @@
* @access public
*/
-class RDF_Model extends RDF_Object
+class RDF_Model
{
/**
* Base URI of the Model.
@@ -80,7 +80,7 @@ function load($filename, $type = null)
* If the statement to be added contains a blankNode with an identifier
* already existing in this model, a new blankNode is generated.
*
- * @param RDF_Object Statement $statement
+ * @param RDF_Node Statement $statement
* @access protected
*/
function _addStatementFromAnotherModel($statement, &$blankNodes_tmp)
View
4 RDF/Model/MDB.php
@@ -14,7 +14,7 @@
*/
require_once 'RDF/Model.php';
require_once 'RDF/Exception.php';
-
+require_once 'PEAR.php';
class RDF_Model_MDB extends RDF_Model
{
/**
@@ -166,7 +166,7 @@ function remove(RDF_Statement $statement)
* @return string
* @access public
*/
- function toString()
+ function __toString()
{
return 'Model_MDB[modelURI=' . $this->modelURI . '; baseURI=' .
$this->getBaseURI() . '; size=' . $this->size() . ']';
View
6 RDF/Model/Memory.php
@@ -154,7 +154,7 @@ function remove(RDF_Statement $statement)
* @access public
* @return string
*/
- function toString()
+ function __toString()
{
return 'Model_Memory[baseURI=' . $this->getBaseURI() . '; size=' . $this->size() . ']';
}
@@ -167,9 +167,9 @@ function toString()
*/
function toStringIncludingTriples()
{
- $dump = $this->toString() . chr(13);
+ $dump = $this->__toString() . chr(13);
foreach($this->triples as $value) {
- $dump .= $value->toString() . chr(13);
+ $dump .= $value->__toString() . chr(13);
}
return $dump;
}
View
4 RDF/Node.php
@@ -14,9 +14,9 @@
* @package model
* @abstract
*/
-class RDF_Node extends RDF_Object
+abstract class RDF_Node
{
} // end:RDFNode
-?>
+?>
View
38 RDF/Object.php
@@ -1,38 +0,0 @@
-<?php
-/**
- * An abstract object.
- * Root object with some general methods, that should be overloaded.
- *
- * @version V0.7
- * @author Chris Bizer <chris@bizer.de>
- * @abstract
- * @package util
- */
-class RDF_Object
-{
- function factory()
- {
- throw new RDF_Exception('Not implemented', RDF_ERROR);
- }
-
- /**
- * Serializes a object into a string
- *
- * @access public
- * @return string
- */
- function toString()
- {
- $objectvars = get_object_vars($this);
- foreach($objectvars as $key => $value) {
- $content.= $key . "='" . $value . "'; ";
- }
- return 'Instance of ' . get_class($this) . '; Properties: ' . $content;
- }
-
-
- public function __toString() {
- return $this->toString();
- }
-}
-
View
2 RDF/Parser.php
@@ -21,7 +21,7 @@
* @access public
*/
-class RDF_Parser extends RDF_Object
+class RDF_Parser
{
var $rdf_parser;
var $model;
View
4 RDF/Resource.php
@@ -98,7 +98,7 @@ function getLocalName()
* @access public
* @return string
*/
- function toString()
+ function __toString()
{
return 'Resource("' . $this->uri . '")';
}
@@ -128,4 +128,4 @@ function equals ($that)
}
}
-?>
+?>
View
2 RDF/Serializer.php
@@ -18,7 +18,7 @@
* @package syntax
* @access public
*/
-class RDF_Serializer extends RDF_Object
+class RDF_Serializer
{
// configuration
var $use_entities;
View
14 RDF/Statement.php
@@ -12,7 +12,7 @@
* @version V0.7
* @package model
*/
-class RDF_Statement extends RDF_Object
+class RDF_Statement
{
/**
* Subject of the statement
@@ -151,9 +151,9 @@ function hashCode()
* @return string
*/
- function toString()
+ function __toString()
{
- return 'Triple(' . $this->subj->toString() . ', ' . $this->pred->toString() . ', ' . $this->obj->toString() . ')';
+ return 'Triple(' . (string)$this->subj . ', ' . (string)$this->pred . ', ' . (string)$this->obj . ')';
}
/**
@@ -164,7 +164,7 @@ function toString()
*/
function toStringSubject()
{
- return $this->subj->toString();
+ return (string)$this->subj;
}
/**
@@ -175,7 +175,7 @@ function toStringSubject()
*/
function toStringPredicate()
{
- return $this->pred->toString();
+ return (string)$this->pred;
}
/**
@@ -186,7 +186,7 @@ function toStringPredicate()
*/
function toStringObject()
{
- return $this->obj->toString();
+ return (string)$this->obj;
}
/**
@@ -347,6 +347,6 @@ function RDF_statementsorter($a, $b)
$x = $a->getObject();
$y = $b->getObject();
- return strcmp($x->toString(), $y->toString());
+ return strcmp((string)$x, (string)$y);
}
?>
View
4 RDF/StatementIterator.php
@@ -12,7 +12,7 @@
* @package util
* @access public
*/
-class RDF_StatementIterator extends RDF_Object
+class RDF_StatementIterator
{
/**
* Reference to the Model_Memory
@@ -165,4 +165,4 @@ function getCurrentPosition()
}
}
-?>
+?>
View
3 RDF/Store/MDB.php
@@ -12,8 +12,9 @@
* @package model
* @access public
*/
+require_once 'PEAR.php';
-class RDF_Store_MDB extends RDF_Object
+class RDF_Store_MDB
{
/**
* Database connection object
View
4 RDF/Util.php
@@ -11,7 +11,7 @@
* @package util
* @access public
*/
-class RDF_Util extends RDF_Object
+class RDF_Util
{
/**
* Extracts the namespace prefix out of a URI.
@@ -249,4 +249,4 @@ function getNodeTypeName($node)
}
} // end: RDF_Util
-?>
+?>
View
2 docs/examples/test_ManipulateModelMemory.php
@@ -49,7 +49,7 @@
$statement = $model->findFirstMatchingStatement($homepage, $description, null);
// Check if something was found and output result
if ($statement) {
- echo $statement->toString();
+ echo $statement;
} else {
echo "Sorry, I didn't find anything.";
}
View
6 docs/examples/test_TraverseModel.php
@@ -29,15 +29,15 @@
$it->moveLast();
$statement = $it->current();
// Traverse model backward and print statements
-echo $statement->toString() . "<BR>";
+echo $statement . "<BR>";
while ($it->hasPrevious()) {
$statement = $it->previous();
- echo $statement->toString() . "<BR>";
+ echo $statement . "<BR>";
}
// Jump to statement 2 and print it
$it->moveTo(2);
$statement = $it->current();
-echo $statement->toString() . "<BR>";
+echo $statement . "<BR>";
?>
</body>
</html>

0 comments on commit f19a92d

Please sign in to comment.