WildcardEmitter.php 997 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\Event;
  4. /**
  5. * This class is an EventEmitter with support for wildcard event handlers.
  6. *
  7. * What this means is that you can emit events like this:
  8. *
  9. * emit('change:firstName')
  10. *
  11. * and listen to this event like this:
  12. *
  13. * on('change:*')
  14. *
  15. * A few notes:
  16. *
  17. * - Wildcards only work at the end of an event name.
  18. * - Currently you can only use 1 wildcard.
  19. * - Using ":" as a separator is optional, but it's highly recommended to use
  20. * some kind of separator.
  21. *
  22. * The WildcardEmitter is a bit slower than the regular Emitter. If your code
  23. * must be very high performance, it might be better to try to use the other
  24. * emitter. For most usage the difference is negligible though.
  25. *
  26. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  27. * @author Evert Pot (http://evertpot.com/)
  28. * @license http://sabre.io/license/ Modified BSD License
  29. */
  30. class WildcardEmitter implements EmitterInterface
  31. {
  32. use WildcardEmitterTrait;
  33. }