Permalink
Browse files

- Add getMethodSource() method.

  • Loading branch information...
1 parent cac51ac commit 05bbd61989eed05ca4462e0a71517d0d8bd91110 @sebastianbergmann committed Jun 23, 2007
Showing with 13 additions and 0 deletions.
  1. +13 −0 PHPUnit/Util/Class.php
View
@@ -153,5 +153,18 @@ public static function getHierarchy($className)
return $classes;
}
+
+ public static function getMethodSource($className, $methodName)
+ {
+ $method = new ReflectionMethod($className, $methodName);
+ $file = file($method->getFileName());
+ $result = '';
+
+ for ($line = $method->getStartLine() - 1; $line <= $method->getEndLine() - 1; $line++) {
+ $result .= $file[$line];
+ }
+
+ return $result;
+ }
}
?>

0 comments on commit 05bbd61

Please sign in to comment.