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 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | */ |
20 | |
21 | namespace Wikimedia\EventRelayer; |
22 | |
23 | use Psr\Log\LoggerAwareInterface; |
24 | use Psr\Log\LoggerInterface; |
25 | use Psr\Log\NullLogger; |
26 | |
27 | /** |
28 | * Base class for reliable event relays |
29 | * |
30 | * @stable to extend |
31 | */ |
32 | abstract class EventRelayer implements LoggerAwareInterface { |
33 | /** @var LoggerInterface */ |
34 | protected $logger; |
35 | |
36 | /** |
37 | * @stable to call |
38 | * |
39 | * @param array $params |
40 | */ |
41 | public function __construct( array $params ) { |
42 | $this->logger = new NullLogger(); |
43 | } |
44 | |
45 | /** |
46 | * @param string $channel |
47 | * @param array $event Event data map |
48 | * @return bool Success |
49 | */ |
50 | final public function notify( $channel, $event ) { |
51 | return $this->doNotify( $channel, [ $event ] ); |
52 | } |
53 | |
54 | /** |
55 | * @param string $channel |
56 | * @param array $events List of event data maps |
57 | * @return bool Success |
58 | */ |
59 | final public function notifyMulti( $channel, $events ) { |
60 | return $this->doNotify( $channel, $events ); |
61 | } |
62 | |
63 | public function setLogger( LoggerInterface $logger ) { |
64 | $this->logger = $logger; |
65 | } |
66 | |
67 | /** |
68 | * @param string $channel |
69 | * @param array $events List of event data maps |
70 | * @return bool Success |
71 | */ |
72 | abstract protected function doNotify( $channel, array $events ); |
73 | } |
74 | |
75 | /** @deprecated class alias since 1.41 */ |
76 | class_alias( EventRelayer::class, 'EventRelayer' ); |