Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
DavCalendarPushJobHandler
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 supports
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 executePush
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 formatSuccessMessage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Dav\Application\Handler;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Modules\Dav\Application\Service\DavAccountResolver;
12use App\Modules\Dav\Application\Service\DavCalendarSyncService;
13use App\Modules\Dav\Application\Service\DavQueueDispatcher;
14use App\Modules\Dav\Domain\Model\DavAccount;
15
16/**
17 * Queue Job Handler for Asynchronous DAV Calendar Event Pushing.
18 *
19 * @package App\Modules\Dav\Application\Handler
20 */
21final readonly class DavCalendarPushJobHandler extends AbstractDavPushJobHandler
22{
23    /**
24     * DavCalendarPushJobHandler constructor.
25     *
26     * @param DavCalendarSyncService $calendarSync    Calendar DAV sync service.
27     * @param DavAccountResolver     $accountResolver User account resolver service.
28     */
29    public function __construct(
30        private DavCalendarSyncService $calendarSync,
31        DavAccountResolver $accountResolver
32    ) {
33        parent::__construct($accountResolver);
34    }
35
36    /**
37     * {@inheritdoc}
38     */
39    public function supports(): string
40    {
41        return DavQueueDispatcher::JOB_CALENDAR_PUSH;
42    }
43
44    /**
45     * {@inheritdoc}
46     */
47    protected function executePush(int $entityId, string $action, DavAccount $account, array $snapshot): void
48    {
49        $this->calendarSync->pushEvent($entityId, $action, $account, $snapshot);
50    }
51
52    /**
53     * {@inheritdoc}
54     */
55    protected function formatSuccessMessage(int $entityId, string $action): string
56    {
57        return sprintf('Successfully pushed calendar event #%d [%s] to CalDAV.', $entityId, $action);
58    }
59}