From fe96e024fdf52333318eade7c042945071957b74 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 25 Mar 2012 15:36:27 +1030 Subject: [PATCH] Swap to exceptions --- RDF/Statement.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/RDF/Statement.php b/RDF/Statement.php index 31d6760..db10d5f 100644 --- a/RDF/Statement.php +++ b/RDF/Statement.php @@ -72,13 +72,8 @@ function factory($subj, $pred, $obj) * @access public * @return object node */ - function setSubject($subj) + function setSubject(RDF_Resource $subj) { - if (!is_a($subj, 'RDF_Resource')) { - $errmsg = 'Resource expected as subject, got unexpected: '. - (is_object($subj) ? get_class($subj) : gettype($subj)); - return RDF::raiseError(RDF_ERROR_UNEXPECTED, null, null, $errmsg); - } $this->subj = $subj; } @@ -99,12 +94,12 @@ function getSubject() * @access public * @return object node */ - function setPredicate($pred) + function setPredicate(RDF_Resource $pred) { - if (!is_a($pred, 'RDF_Resource') || is_a($pred, 'RDF_BlankNode')) { + if (is_a($pred, 'RDF_BlankNode')) { $errmsg = 'Resource expected as predicate, no blank node allowed, got unexpected: '. (is_object($pred) ? get_class($pred) : gettype($pred)); - return RDF::raiseError(RDF_ERROR_UNEXPECTED, null, null, $errmsg); + throw new InvalidArgumentException($errmsg); } $this->pred = $pred; } @@ -131,7 +126,7 @@ function setObject($obj) if (!(is_a($obj, 'RDF_Resource') or is_a($obj, 'RDF_Literal'))) { $errmsg = 'Resource or Literal expected as object, got unexpected: '. (is_object($obj) ? get_class($obj) : gettype($obj)); - return RDF::raiseError(RDF_ERROR_UNEXPECTED, null, null, $errmsg); + throw new InvalidArgumentException($errmsg); } $this->obj = $obj; } @@ -414,4 +409,4 @@ function RDF_statementsorter($a, $b) return strcmp($x->toString(), $y->toString()); } -?> \ No newline at end of file +?>