MockFileFinder.php 838 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Drupal\Component\Annotation\Reflection;
  3. use Doctrine\Common\Reflection\ClassFinderInterface;
  4. /**
  5. * Defines a mock file finder that only returns a single filename.
  6. *
  7. * This can be used with Doctrine\Common\Reflection\StaticReflectionParser if
  8. * the filename is known and inheritance is not a concern (for example, if
  9. * only the class annotation is needed).
  10. */
  11. class MockFileFinder implements ClassFinderInterface {
  12. /**
  13. * The only filename this finder ever returns.
  14. *
  15. * @var string
  16. */
  17. protected $filename;
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function findFile($class) {
  22. return $this->filename;
  23. }
  24. /**
  25. * Creates new mock file finder objects.
  26. */
  27. public static function create($filename) {
  28. $object = new static();
  29. $object->filename = $filename;
  30. return $object;
  31. }
  32. }