| Total Complexity | 4 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | class SnsEventHandler extends AbstractProcessingHandler |
||
| 21 | { |
||
| 22 | const DATE_FORMAT = 'Y-m-d\TH:i:s.uO'; |
||
| 23 | |||
| 24 | /** @var SnsClient */ |
||
| 25 | private $client; |
||
| 26 | /** @var string */ |
||
| 27 | private $topic; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param SnsClient $client |
||
| 31 | * @param string $topic aws TopicArn |
||
| 32 | */ |
||
| 33 | 5 | public function __construct(SnsClient $client, $topic) |
|
| 34 | { |
||
| 35 | 5 | $this->client = $client; |
|
| 36 | 5 | $this->topic = $topic; |
|
| 37 | 5 | parent::__construct(); |
|
| 38 | 5 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Event handlers handle all events by default |
||
| 42 | * |
||
| 43 | * @param array $record |
||
| 44 | * |
||
| 45 | * @return bool always returns true |
||
| 46 | */ |
||
| 47 | 2 | public function isHandling(array $record) |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | * |
||
| 55 | * @param array $record |
||
| 56 | */ |
||
| 57 | 1 | protected function write(array $record) |
|
| 58 | { |
||
| 59 | 1 | $this->client->publish([ |
|
| 60 | 1 | 'TopicArn' => $this->topic, |
|
| 61 | 1 | 'Message' => $record['formatted'], |
|
| 62 | ]); |
||
| 63 | 1 | } |
|
| 64 | |||
| 65 | /** |
||
| 66 | * @return JsonDateAwareFormatter |
||
| 67 | */ |
||
| 68 | 1 | protected function getDefaultFormatter() |
|
| 71 | } |
||
| 72 | } |
||
| 73 |