/**
  * Creates a new Descriptor from the given Reflector.
  *
  * @param ExampleTag $data
  *
  * @throws \InvalidArgumentException if the provided parameter is not of type ExampleTag; the interface won't let
  *   up typehint the signature.
  *
  * @return ExampleDescriptor
  */
 public function create($data)
 {
     if (!$data instanceof ExampleTag) {
         throw new \InvalidArgumentException('The ExampleAssembler expected an ExampleTag object to base the descriptor on');
     }
     $descriptor = new ExampleDescriptor($data->getName());
     $descriptor->setFilePath((string) $data->getFilePath());
     $descriptor->setStartingLine($data->getStartingLine());
     $descriptor->setLineCount($data->getLineCount());
     $descriptor->setDescription($data->getDescription());
     $descriptor->setExample($this->finder->find($descriptor));
     return $descriptor;
 }
 /**
  * @covers phpDocumentor\Descriptor\Example\Finder::find
  * @covers phpDocumentor\Descriptor\Example\Finder::getExampleFileContents
  */
 public function testErrorMessageIsReturnedIfFileIsNotFound()
 {
     $filename = 'doesNotExist.txt';
     $descriptor = $this->givenADescriptorWithExamplePath($filename);
     $result = $this->fixture->find($descriptor);
     $this->assertSame("** File not found : {$filename} **", $result);
 }
 /**
  * Instructs the finder mock to return the given text when an example is requested and verifies that that is only
  * done once.
  *
  * @param string $exampleText
  *
  * @return void
  */
 private function whenExampleTxtFileContainsAndMustBeCalledOnlyOnce($exampleText)
 {
     $this->finderMock->shouldReceive('find')->once()->andReturn($exampleText);
 }
 /**
  * Instructs the finder dependency to return the given text when an example file is to be found.
  *
  * @param string $exampleText
  *
  * @return void
  */
 private function whenExampleFileContains($exampleText)
 {
     $this->finderMock->shouldReceive('find')->andReturn($exampleText);
 }