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
DavContactPushJobHandler
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\DavContactSyncService;
13use App\Modules\Dav\Application\Service\DavQueueDispatcher;
14use App\Modules\Dav\Domain\Model\DavAccount;
15
16/**
17 * Queue Job Handler for Asynchronous DAV Contact Pushing.
18 *
19 * @package App\Modules\Dav\Application\Handler
20 */
21final readonly class DavContactPushJobHandler extends AbstractDavPushJobHandler
22{
23    /**
24     * DavContactPushJobHandler constructor.
25     *
26     * @param DavContactSyncService $contactSync     Contacts CardDAV sync service.
27     * @param DavAccountResolver    $accountResolver User account resolver service.
28     */
29    public function __construct(
30        private DavContactSyncService $contactSync,
31        DavAccountResolver $accountResolver
32    ) {
33        parent::__construct($accountResolver);
34    }
35
36    /**
37     * {@inheritdoc}
38     */
39    public function supports(): string
40    {
41        return DavQueueDispatcher::JOB_CONTACT_PUSH;
42    }
43
44    /**
45     * {@inheritdoc}
46     */
47    protected function executePush(int $entityId, string $action, DavAccount $account, array $snapshot): void
48    {
49        $this->contactSync->pushContact($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 contact #%d [%s] to CardDAV.', $entityId, $action);
58    }
59}