diff options
author | michaelward82 <[email protected]> | 2013-09-14 14:35:54 +0100 |
---|---|---|
committer | Simon Holywell <[email protected]> | 2013-12-26 16:18:40 +0000 |
commit | 3530b21fec1ee958a2c0d9c31ed83d53ac66ceee (patch) | |
tree | 7bc531024813e92e7529bf025e5a6e7d652d5a1b /idiorm.php | |
parent | 909c6da9d5a8fcff09d6f5655eeb677cde5acfb6 (diff) |
Adds new IdiormMethodMissingException class for missing magic method calls to ORM and IdiormResultSet
Diffstat (limited to 'idiorm.php')
-rw-r--r-- | idiorm.php | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1886,7 +1886,11 @@ { $method = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name)); - return call_user_func_array(array($this, $method), $arguments); + if (method_exists($this, $method)) { + return call_user_func_array(array($this, $method), $arguments); + } else { + throw new IdiormMethodMissingException("Method $name() does not exist in class " . get_class($this)); + } } /** @@ -2136,7 +2140,11 @@ */ public function __call($method, $params = array()) { foreach($this->_results as $model) { - call_user_func_array(array($model, $method), $params); + if (method_exists($model, $method)) { + call_user_func_array(array($model, $method), $params); + } else { + throw new IdiormMethodMissingException("Method $method() does not exist in class " . get_class($this)); + } } return $this; } @@ -2146,3 +2154,5 @@ * A placeholder for exceptions eminating from the IdiormString class */ class IdiormStringException extends Exception {} + + class IdiormMethodMissingException extends Exception {}
\ No newline at end of file |