Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| DavSyncResult | |
100.00% |
10 / 10 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| addError | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toSummary | |
100.00% |
8 / 8 |
|
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 Synchronization Result DTO. |
| 13 | * |
| 14 | * Tracks counters and status messages for batch synchronization runs. |
| 15 | * |
| 16 | * @package App\Modules\Dav\Domain\Model |
| 17 | */ |
| 18 | final class DavSyncResult |
| 19 | { |
| 20 | /** |
| 21 | * DavSyncResult constructor. |
| 22 | * |
| 23 | * @param int $createdCount Number of newly created local or remote records. |
| 24 | * @param int $updatedCount Number of modified records updated. |
| 25 | * @param int $deletedCount Number of deleted records purged. |
| 26 | * @param int $skippedCount Number of unmodified records skipped. |
| 27 | * @param array<int, string> $errors Collection of encountered error messages. |
| 28 | */ |
| 29 | public function __construct( |
| 30 | public int $createdCount = 0, |
| 31 | public int $updatedCount = 0, |
| 32 | public int $deletedCount = 0, |
| 33 | public int $skippedCount = 0, |
| 34 | public array $errors = [] |
| 35 | ) { |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Records an error message into the result collection. |
| 40 | * |
| 41 | * @param string $error Error description text. |
| 42 | * @return void |
| 43 | */ |
| 44 | public function addError(string $error): void |
| 45 | { |
| 46 | $this->errors[] = $error; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns a human-readable summary message. |
| 51 | * |
| 52 | * @return string Formatted execution summary. |
| 53 | */ |
| 54 | public function toSummary(): string |
| 55 | { |
| 56 | return sprintf( |
| 57 | 'Created: %d, Updated: %d, Deleted: %d, Skipped: %d, Errors: %d', |
| 58 | $this->createdCount, |
| 59 | $this->updatedCount, |
| 60 | $this->deletedCount, |
| 61 | $this->skippedCount, |
| 62 | count($this->errors) |
| 63 | ); |
| 64 | } |
| 65 | } |