Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| DavAccount | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCalendarUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAddressBookUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Dav\Domain\Model; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * DAV Account Value Object. |
| 13 | * |
| 14 | * Represents an authenticated user connection profile for CalDAV / CardDAV server. |
| 15 | * |
| 16 | * @package App\Modules\Dav\Domain\Model |
| 17 | */ |
| 18 | final readonly class DavAccount |
| 19 | { |
| 20 | /** |
| 21 | * DavAccount constructor. |
| 22 | * |
| 23 | * @param int $userId Local CRM system user identifier. |
| 24 | * @param string $email Full email address and DAV principal username. |
| 25 | * @param string $password Mailbox password for HTTP Basic Authentication. |
| 26 | * @param string $baseUrl Base DAV root endpoint URL (e.g. https://mail.ammonly.com/SOGo/dav). |
| 27 | */ |
| 28 | public function __construct( |
| 29 | public int $userId, |
| 30 | public string $email, |
| 31 | public string $password, |
| 32 | public string $baseUrl = 'https://mail.ammonly.com/SOGo/dav' |
| 33 | ) { |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Returns the user-specific CalDAV personal calendar collection URL. |
| 38 | * |
| 39 | * @return string Full calendar collection URI. |
| 40 | */ |
| 41 | public function getCalendarUrl(): string |
| 42 | { |
| 43 | return sprintf('%s/%s/Calendar/personal/', rtrim($this->baseUrl, '/'), $this->email); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns the user-specific CardDAV personal address book collection URL. |
| 48 | * |
| 49 | * @return string Full address book collection URI. |
| 50 | */ |
| 51 | public function getAddressBookUrl(): string |
| 52 | { |
| 53 | return sprintf('%s/%s/Contacts/personal/', rtrim($this->baseUrl, '/'), $this->email); |
| 54 | } |
| 55 | } |