Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.33% |
5 / 6 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| InAppChannel | |
83.33% |
5 / 6 |
|
66.67% |
2 / 3 |
4.07 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| supports | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| deliver | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Service\Notification; |
| 10 | |
| 11 | use OCP\Notification\IManager; |
| 12 | |
| 13 | final class InAppChannel implements NotificationChannel { |
| 14 | public function __construct( |
| 15 | private IManager $manager, |
| 16 | ) { |
| 17 | } |
| 18 | |
| 19 | #[\Override] |
| 20 | public function supports(string $channel): bool { |
| 21 | return $channel === 'nextcloud'; |
| 22 | } |
| 23 | |
| 24 | #[\Override] |
| 25 | public function deliver(NotificationMessage $message): void { |
| 26 | $payload = $message->payload; |
| 27 | if (!$payload instanceof InAppPayload) { |
| 28 | throw new \InvalidArgumentException('Invalid in-app notification payload'); |
| 29 | } |
| 30 | $this->manager->notify($payload->notification); |
| 31 | } |
| 32 | } |