/** * Replaces the example tags in the description with the contents of the found example. * * @param DescriptorAbstract $element * * @return string */ protected function replaceInlineExamples(DescriptorAbstract $element) { $description = $element->getDescription(); $matches = array(); if (!$description || !preg_match_all('/\\{@example\\s(.+?)\\}/', $description, $matches) || count($matches[0]) < 1) { return $description; } $matched = array(); foreach ($matches[0] as $index => $match) { if (isset($matched[$match])) { continue; } $matched[$match] = true; $exampleReflector = new ExampleTag('example', $matches[1][$index]); $example = $this->exampleAssembler->create($exampleReflector); $replacement = '`' . $example->getExample() . '`'; if ($example->getDescription()) { $replacement = '*' . $example->getDescription() . '*' . $replacement; } $description = str_replace($match, $replacement, $description); } return $description; }
/** * @covers \phpDocumentor\Descriptor\Builder\Reflector\Tags\ExampleAssembler::create * @expectedException InvalidArgumentException */ public function testExceptionIsThrownIfTheWrongObjectIsPassed() { $this->fixture->create('this is an error'); }