Skip to content

Commit

Permalink
Swap to exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Mar 25, 2012
1 parent fc90f7c commit fe96e02
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions RDF/Statement.php
Expand Up @@ -72,13 +72,8 @@ function factory($subj, $pred, $obj)
* @access public * @access public
* @return object node * @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; $this->subj = $subj;
} }


Expand All @@ -99,12 +94,12 @@ function getSubject()
* @access public * @access public
* @return object node * @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: '. $errmsg = 'Resource expected as predicate, no blank node allowed, got unexpected: '.
(is_object($pred) ? get_class($pred) : gettype($pred)); (is_object($pred) ? get_class($pred) : gettype($pred));
return RDF::raiseError(RDF_ERROR_UNEXPECTED, null, null, $errmsg); throw new InvalidArgumentException($errmsg);
} }
$this->pred = $pred; $this->pred = $pred;
} }
Expand All @@ -131,7 +126,7 @@ function setObject($obj)
if (!(is_a($obj, 'RDF_Resource') or is_a($obj, 'RDF_Literal'))) { if (!(is_a($obj, 'RDF_Resource') or is_a($obj, 'RDF_Literal'))) {
$errmsg = 'Resource or Literal expected as object, got unexpected: '. $errmsg = 'Resource or Literal expected as object, got unexpected: '.
(is_object($obj) ? get_class($obj) : gettype($obj)); (is_object($obj) ? get_class($obj) : gettype($obj));
return RDF::raiseError(RDF_ERROR_UNEXPECTED, null, null, $errmsg); throw new InvalidArgumentException($errmsg);
} }
$this->obj = $obj; $this->obj = $obj;
} }
Expand Down Expand Up @@ -414,4 +409,4 @@ function RDF_statementsorter($a, $b)


return strcmp($x->toString(), $y->toString()); return strcmp($x->toString(), $y->toString());
} }
?> ?>

0 comments on commit fe96e02

Please sign in to comment.