Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SyncResult
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 isSuccess
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 toArray
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace BuyerKiosk\Employee;
4
5/**
6 * Data Transfer Object for employee sync results
7 *
8 * Contains statistics and errors from employee synchronization operations.
9 * Used by providers that support syncing from external sources (WhenIWork, Homebase).
10 */
11class SyncResult
12{
13    /**
14     * Number of employees created during sync
15     * @var int
16     */
17    public int $created = 0;
18
19    /**
20     * Number of employees updated during sync
21     * @var int
22     */
23    public int $updated = 0;
24
25    /**
26     * Number of employees deactivated during sync
27     * @var int
28     */
29    public int $deactivated = 0;
30
31    /**
32     * Number of employees reactivated during sync
33     * @var int
34     */
35    public int $reactivated = 0;
36
37    /**
38     * Number of employees merged (matched to existing user)
39     * @var int
40     */
41    public int $merged = 0;
42
43    /**
44     * Array of error messages encountered during sync
45     * @var array
46     */
47    public array $errors = [];
48
49    /**
50     * Check if sync was successful (no errors)
51     *
52     * @return bool True if no errors occurred
53     */
54    public function isSuccess(): bool
55    {
56        return empty($this->errors);
57    }
58
59    /**
60     * Convert sync result to array for API responses
61     *
62     * @return array Associative array with sync statistics
63     */
64    public function toArray(): array
65    {
66        return [
67            'success' => $this->isSuccess(),
68            'created' => $this->created,
69            'updated' => $this->updated,
70            'deactivated' => $this->deactivated,
71            'reactivated' => $this->reactivated,
72            'merged' => $this->merged,
73            'errors' => $this->errors,
74        ];
75    }
76}