$builder
$builder : \phpDocumentor\Descriptor\ProjectDescriptorBuilder|null
Base class for all assemblers.
$builder : \phpDocumentor\Descriptor\ProjectDescriptorBuilder|null
getBuilder() : null|\phpDocumentor\Descriptor\ProjectDescriptorBuilder
Returns the builder for this Assembler or null if none is set.
setBuilder(\phpDocumentor\Descriptor\ProjectDescriptorBuilder $builder) : void
Registers the Builder with this Assembler.
The Builder may be used to recursively assemble Descriptors using the ProjectDescriptorBuilder::buildDescriptor() method.
\phpDocumentor\Descriptor\ProjectDescriptorBuilder | $builder |
assembleDocBlock(\phpDocumentor\Reflection\DocBlock|null $docBlock, \phpDocumentor\Descriptor\DescriptorAbstract $target) : void
Assemble DocBlock.
\phpDocumentor\Reflection\DocBlock|null | $docBlock | |
\phpDocumentor\Descriptor\DescriptorAbstract | $target |
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @copyright 2010-2014 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Descriptor\Builder\Reflector;
use phpDocumentor\Descriptor\Builder\AssemblerAbstract as BaseAssembler;
use phpDocumentor\Descriptor\Collection;
use phpDocumentor\Descriptor\DescriptorAbstract;
use phpDocumentor\Reflection\DocBlock;
abstract class AssemblerAbstract extends BaseAssembler
{
/**
* Assemble DocBlock.
*
* @param DocBlock|null $docBlock
* @param DescriptorAbstract $target
*
* @return void
*/
protected function assembleDocBlock($docBlock, $target)
{
if (!$docBlock) {
return;
}
$target->setSummary($docBlock->getShortDescription());
$target->setDescription($docBlock->getLongDescription()->getContents());
/** @var DocBlock\Tag $tag */
foreach ($docBlock->getTags() as $tag) {
$tagDescriptor = $this->builder->buildDescriptor($tag);
// allow filtering of tags
if (!$tagDescriptor) {
continue;
}
$target->getTags()
->get($tag->getName(), new Collection())
->add($tagDescriptor);
}
}
/**
* Extracts the package from the DocBlock.
*
* @param DocBlock $docBlock
*
* @return string|null
*/
protected function extractPackageFromDocBlock($docBlock)
{
$packageTags = $docBlock ? $docBlock->getTagsByName('package') : null;
if (! $packageTags) {
return null;
}
/** @var DocBlock\Tag $tag */
$tag = reset($packageTags);
return trim($tag->getContent());
}
}