email = $email; $this->self = $self; $this->identifier = $identifier; $this->displayName = $displayName; $this->responseStatus = $responseStatus; $this->optional = $optional; } /** * @param array $data * * @return GoogleCalendarEventAttendeeValue */ public static function createFromJsonArray(array $data): GoogleCalendarEventAttendeeValue { if (!isset($data['email'])) { throw new InvalidArgumentException('Invalid data format.'); } $email = $data['email']; $self = false; if (isset($data['self'])) { $self = (bool)$data['self']; } $displayName = ''; if (isset($data['displayName'])) { $displayName = $data['displayName']; } $id = ''; if (isset($data['id'])) { $id = $data['id']; } $responseStatus = ''; if (isset($data['responseStatus'])) { $responseStatus = $data['responseStatus']; } return new self($email, $displayName, false, $id, $responseStatus, $self); } /** * @return array */ public function toDataArray(): array { $data = []; $data['email'] = $this->getEmail(); $data['displayName'] = $this->getDisplayName(); $data['optional'] = $this->isOptional(); if ($this->getIdentifier() !== '') { $data['id'] = $this->getIdentifier(); } if ($this->responseStatus !== '') { $data['responseStatus'] = $this->responseStatus; } return $data; } /** * @return string */ public function getEmail(): string { return $this->email; } /** * @return bool */ public function isSelf(): bool { return $this->self; } /** * @return string */ public function getDisplayName(): string { $display = $this->displayName; if ($display === '' || $display === null) { $display = $this->email; } return $display; } /** * @return string */ public function getIdentifier(): string { return $this->identifier; } /** * @return bool */ public function isAttending(): bool { return ( $this->responseStatus === self::STATUS_ACCEPTED || $this->responseStatus === self::STATUS_TENTATIVE || $this->responseStatus === self::STATUS_NEEDSACTION ); } /** * @return bool */ public function isOptional(): bool { return $this->optional; } }