id = $id; $this->eventId = $eventId; $this->userId = $userId; $this->groupId = $groupId; $this->addressId = $addressId; $this->email = $email; } /** * @param array $data * * @throws InvalidArgumentException * * @return CalendarEventUser */ public static function fromDbState(array $data): CalendarEventUser { if (!isset($data['id'], $data['event_id'], $data['user_id'], $data['group_id'])) { throw new InvalidArgumentException('Invalid or incomplete dataset.'); } $instance = new self(); $instance->setId((int)$data['id']); $instance->setEventId((int)$data['event_id']); $instance->setUserId((int)$data['user_id']); $instance->setGroupId((int)$data['group_id']); if (array_key_exists('address_id', $data)) { $instance->setAddressId((int)$data['address_id']); } if (isset($data['email']) && $data['email'] !== '') { $instance->setEmail($data['email']); } return $instance; } /** * @return array */ public function toArray(): array { return [ 'id' => $this->getId(), 'event_id' => $this->getEventId(), 'user_id' => $this->getUserId(), 'group_id' => $this->getGroupId(), ]; } /** * @return int */ public function getId(): int { return $this->id; } /** * @param int $id */ public function setId(int $id): void { $this->id = $id; } /** * @return int */ public function getEventId(): int { return $this->eventId; } /** * @param int $eventId */ public function setEventId(int $eventId): void { $this->eventId = $eventId; } /** * @return int */ public function getUserId(): int { return $this->userId; } /** * @param int $userId */ public function setUserId(int $userId): void { $this->userId = $userId; } /** * @return int */ public function getGroupId(): int { return $this->groupId; } /** * @param int $groupId */ public function setGroupId(int $groupId): void { $this->groupId = $groupId; } /** * @return int */ public function getAddressId(): int { return $this->addressId; } /** * @param int $addressId */ public function setAddressId(int $addressId): void { $this->addressId = $addressId; } /** * @return string */ public function getEmail(): string { return $this->email; } /** * @param string $email */ public function setEmail(string $email): void { $this->email = $email; } }