Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| EventRelayer | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| notify | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| notifyMulti | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setLogger | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| doNotify | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace Wikimedia\EventRelayer; |
| 8 | |
| 9 | use Psr\Log\LoggerAwareInterface; |
| 10 | use Psr\Log\LoggerInterface; |
| 11 | use Psr\Log\NullLogger; |
| 12 | |
| 13 | /** |
| 14 | * Base class for reliable event relays |
| 15 | * |
| 16 | * @stable to extend |
| 17 | */ |
| 18 | abstract class EventRelayer implements LoggerAwareInterface { |
| 19 | /** @var LoggerInterface */ |
| 20 | protected $logger; |
| 21 | |
| 22 | /** |
| 23 | * @stable to call |
| 24 | * |
| 25 | * @param array $params |
| 26 | */ |
| 27 | public function __construct( array $params ) { |
| 28 | $this->logger = new NullLogger(); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @param string $channel |
| 33 | * @param array $event Event data map |
| 34 | * @return bool Success |
| 35 | */ |
| 36 | final public function notify( $channel, $event ) { |
| 37 | return $this->doNotify( $channel, [ $event ] ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @param string $channel |
| 42 | * @param array $events List of event data maps |
| 43 | * @return bool Success |
| 44 | */ |
| 45 | final public function notifyMulti( $channel, $events ) { |
| 46 | return $this->doNotify( $channel, $events ); |
| 47 | } |
| 48 | |
| 49 | public function setLogger( LoggerInterface $logger ): void { |
| 50 | $this->logger = $logger; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @param string $channel |
| 55 | * @param array $events List of event data maps |
| 56 | * @return bool Success |
| 57 | */ |
| 58 | abstract protected function doNotify( $channel, array $events ); |
| 59 | } |
| 60 | |
| 61 | /** @deprecated class alias since 1.41 */ |
| 62 | class_alias( EventRelayer::class, 'EventRelayer' ); |