Browse files

Added getParamDescription() method.

  • Loading branch information...
1 parent 4f5d928 commit 99af0bffc4e342065a4dba701fe878017d184a60 Stefan Priebsch committed Oct 11, 2009
Showing with 22 additions and 0 deletions.
  1. +9 −0 DocBlock.php
  2. +13 −0 DocBlockTest.php
View
9 DocBlock.php
@@ -281,6 +281,15 @@ public function getParamName($index)
return substr($param, 0, $pos);
}
+ public function getParamDescription($index)
+ {
+ $param = $this->getParam($index);
+ $paramType = $this->getParamType($index);
+ $paramName = $this->getParamName($index);
+
+ return substr($param, strlen($paramType) + strlen($paramName) + 2);
+ }
+
public function getNumberOfParamTags()
{
return sizeof($this->paramTags);
View
13 DocBlockTest.php
@@ -129,6 +129,19 @@ public function testGetParamTypeForParameterWithoutDescription()
$this->assertEquals('string', $this->docBlock->getParamType(0));
}
+ public function testGetParamDescription()
+ {
+ $this->docBlock->parse(file_get_contents(__DIR__ . '/_testdata/docblock'));
+ $this->assertEquals('The foo parameter', $this->docBlock->getParamDescription(0));
+ $this->assertEquals('Number of bars', $this->docBlock->getParamDescription(1));
+ }
+
+ public function testGetParamDescriptionReturnsEmptyStringOnParameterWithoutDescription()
+ {
+ $this->docBlock->parse(file_get_contents(__DIR__ . '/_testdata/param_without_description'));
+ $this->assertEquals('', $this->docBlock->getParamDescription(0));
+ }
+
public function testGetReturn()
{
$this->docBlock->parse(file_get_contents(__DIR__ . '/_testdata/docblock'));

0 comments on commit 99af0bf

Please sign in to comment.