/**
  * Filter Descriptor with based on visibility.
  *
  * @param DescriptorAbstract $value
  *
  * @return DescriptorAbstract|null
  */
 public function filter($value)
 {
     if ($value instanceof VisibilityInterface && !$this->builder->isVisibilityAllowed($value->getVisibility())) {
         return null;
     }
     return $value;
 }
예제 #2
0
 /**
  * If the ProjectDescriptor's settings allow internal tags then return the Descriptor, otherwise null to filter it.
  *
  * @param DescriptorAbstract $value
  *
  * @return DescriptorAbstract|null
  */
 public function filter($value)
 {
     $isInternalAllowed = $this->builder->isVisibilityAllowed(Settings::VISIBILITY_INTERNAL);
     if ($isInternalAllowed) {
         $value->setDescription(preg_replace('/{@internal\\ (.+)}}/', '$1', $value->getDescription()));
         return $value;
     }
     // remove inline @internal tags
     $value->setDescription(preg_replace('/{@internal\\ .+}}/', '', $value->getDescription()));
     // if internal elements are not allowed; filter this element
     if ($value->getTags()->get('internal')) {
         return null;
     }
     return $value;
 }
 /**
  * @covers phpDocumentor\Descriptor\ProjectDescriptorBuilder::isVisibilityAllowed
  */
 public function testDeterminesWhetherASpecificVisibilityIsAllowedToBeIncluded()
 {
     $projectDescriptorName = 'My Descriptor';
     $projectDescriptorMock = new ProjectDescriptor($projectDescriptorName);
     $projectDescriptorMock->getSettings()->setVisibility(Settings::VISIBILITY_PUBLIC);
     $this->fixture->setProjectDescriptor($projectDescriptorMock);
     $this->assertTrue($this->fixture->isVisibilityAllowed(Settings::VISIBILITY_PUBLIC));
     $this->assertFalse($this->fixture->isVisibilityAllowed(Settings::VISIBILITY_PRIVATE));
 }