Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add __toString() support to the ObjectProxy.

  • Loading branch information...
commit 6b5e0a23c1e291952dd54b0e5e2d486a39d15258 1 parent 30a521b
@saltybeagle saltybeagle authored
View
7 src/Templates/Savant/BadMethodCallException.php
@@ -0,0 +1,7 @@
+<?php
+namespace pear2\Templates\Savant;
+
+class BadMethodCallException extends \BadMethodCallException implements Exception
+{
+
+}
View
8 src/Templates/Savant/ObjectProxy.php
@@ -169,4 +169,12 @@ public static function factory($object, $savant)
}
return new self($object, $savant);
}
+
+ function __toString()
+ {
+ if (method_exists($this->object, '__toString')) {
+ return $this->savant->escape($this->object->__toString());
+ }
+ throw new BadMethodCallException('Object of class '.$this->__getClass().' could not be converted to string');
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.