Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Component/Annotation/Reflection/MockFileFinder.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Component\Annotation\Reflection; |
Chris@0 | 4 |
Chris@0 | 5 use Doctrine\Common\Reflection\ClassFinderInterface; |
Chris@0 | 6 |
Chris@0 | 7 /** |
Chris@0 | 8 * Defines a mock file finder that only returns a single filename. |
Chris@0 | 9 * |
Chris@0 | 10 * This can be used with Doctrine\Common\Reflection\StaticReflectionParser if |
Chris@0 | 11 * the filename is known and inheritance is not a concern (for example, if |
Chris@0 | 12 * only the class annotation is needed). |
Chris@0 | 13 */ |
Chris@0 | 14 class MockFileFinder implements ClassFinderInterface { |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * The only filename this finder ever returns. |
Chris@0 | 18 * |
Chris@0 | 19 * @var string |
Chris@0 | 20 */ |
Chris@0 | 21 protected $filename; |
Chris@0 | 22 |
Chris@0 | 23 /** |
Chris@0 | 24 * {@inheritdoc} |
Chris@0 | 25 */ |
Chris@0 | 26 public function findFile($class) { |
Chris@0 | 27 return $this->filename; |
Chris@0 | 28 } |
Chris@0 | 29 |
Chris@0 | 30 /** |
Chris@0 | 31 * Creates new mock file finder objects. |
Chris@0 | 32 */ |
Chris@0 | 33 public static function create($filename) { |
Chris@0 | 34 $object = new static(); |
Chris@0 | 35 $object->filename = $filename; |
Chris@0 | 36 return $object; |
Chris@0 | 37 } |
Chris@0 | 38 |
Chris@0 | 39 } |