Skip to content
Browse files

Swap to exceptions

  • Loading branch information...
1 parent fc90f7c commit fe96e024fdf52333318eade7c042945071957b74 @CloCkWeRX CloCkWeRX committed Mar 25, 2012
Showing with 6 additions and 11 deletions.
  1. +6 −11 RDF/Statement.php
View
17 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());
}
-?>
+?>

0 comments on commit fe96e02

Please sign in to comment.
Something went wrong with that request. Please try again.