Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
| UserEmployeeLink | |
0.00% |
0 / 25 |
|
0.00% |
0 / 9 |
110 | |
0.00% |
0 / 1 |
| fromRow | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTypeNum | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getEmployeeId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLinkType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLinkedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLinkedBy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BuyerKiosk\UserEmployee; |
| 4 | |
| 5 | /** |
| 6 | * Entity representing a link between a uf_user and an employee record |
| 7 | * |
| 8 | * This class represents a single link between a user account in the central |
| 9 | * kiosk_users database and an employee record in a store-specific database. |
| 10 | */ |
| 11 | class UserEmployeeLink |
| 12 | { |
| 13 | private int $id; |
| 14 | private int $userId; |
| 15 | private string $typeNum; |
| 16 | private int $employeeId; |
| 17 | private string $linkType; |
| 18 | private string $linkedAt; |
| 19 | private ?int $linkedBy; |
| 20 | |
| 21 | /** |
| 22 | * Create UserEmployeeLink from database row |
| 23 | * |
| 24 | * @param array $row Associative array from database query |
| 25 | * @return self New UserEmployeeLink instance |
| 26 | */ |
| 27 | public static function fromRow(array $row): self |
| 28 | { |
| 29 | $link = new self(); |
| 30 | $link->id = (int) $row['id']; |
| 31 | $link->userId = (int) $row['userId']; |
| 32 | $link->typeNum = $row['typeNum']; |
| 33 | $link->employeeId = (int) $row['employeeId']; |
| 34 | $link->linkType = $row['linkType'] ?? 'manual'; |
| 35 | $link->linkedAt = $row['linkedAt']; |
| 36 | $link->linkedBy = isset($row['linkedBy']) ? (int) $row['linkedBy'] : null; |
| 37 | return $link; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Get link ID |
| 42 | * @return int |
| 43 | */ |
| 44 | public function getId(): int |
| 45 | { |
| 46 | return $this->id; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get user ID (FK to uf_user.id) |
| 51 | * @return int |
| 52 | */ |
| 53 | public function getUserId(): int |
| 54 | { |
| 55 | return $this->userId; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Get store typeNum |
| 60 | * @return string |
| 61 | */ |
| 62 | public function getTypeNum(): string |
| 63 | { |
| 64 | return $this->typeNum; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Get employee ID (FK to employees.employeeID) |
| 69 | * @return int |
| 70 | */ |
| 71 | public function getEmployeeId(): int |
| 72 | { |
| 73 | return $this->employeeId; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Get link type (auto_name, auto_login, manual, promotion) |
| 78 | * @return string |
| 79 | */ |
| 80 | public function getLinkType(): string |
| 81 | { |
| 82 | return $this->linkType; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Get timestamp when link was created |
| 87 | * @return string |
| 88 | */ |
| 89 | public function getLinkedAt(): string |
| 90 | { |
| 91 | return $this->linkedAt; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Get ID of user who created the link (null for auto-linking) |
| 96 | * @return int|null |
| 97 | */ |
| 98 | public function getLinkedBy(): ?int |
| 99 | { |
| 100 | return $this->linkedBy; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Convert to array for API responses |
| 105 | * |
| 106 | * @return array Associative array of all link data |
| 107 | */ |
| 108 | public function toArray(): array |
| 109 | { |
| 110 | return [ |
| 111 | 'id' => $this->id, |
| 112 | 'userId' => $this->userId, |
| 113 | 'typeNum' => $this->typeNum, |
| 114 | 'employeeId' => $this->employeeId, |
| 115 | 'linkType' => $this->linkType, |
| 116 | 'linkedAt' => $this->linkedAt, |
| 117 | 'linkedBy' => $this->linkedBy, |
| 118 | ]; |
| 119 | } |
| 120 | } |