id = $id; $this->createdAt = $createdAt; $this->identifier = $identifier; $this->expiresAt = $expires; $this->updatedAt = $updatedAt; $this->deviceLabel = $deviceLabel; } public function getId(): ?string { return $this->id; } public function getCreatedAt(): ?string { return $this->createdAt; } public function getIdentifier(): ?string { return $this->identifier; } public function getExpiresAt(): ?string { return $this->expiresAt; } public function getUpdatedAt(): ?string { return $this->updatedAt; } public function getDeviceLabel(): ?string { return $this->deviceLabel; } public function withUpdatedExpiration(string $updatedAt, string $expiresAt): Session { $this->updatedAt = $updatedAt; $this->expiresAt = $expiresAt; return $this; } public function withUpdateAt(?string $updatedAt = null): Session { $this->updatedAt = $updatedAt ?? date(DATE_ATOM); return $this; } public static function fromArray($array): Session { $id = $array['id'] ?? null; $createdAt = $array['createdAt'] ?? date(DATE_ATOM); $identifier = $array['identifier'] ?? null; $expires = $array['expiresAt'] ?? null; if (is_int($expires)) { $expires = date(DATE_ATOM, $expires); } $updatedAt = $array['updatedAt'] ?? date(DATE_ATOM); $deviceLabel = $array['deviceLabel'] ?? null; return new Session($id, $createdAt, $identifier, $expires, $updatedAt, $deviceLabel); } /** * @return Session[] */ public static function fromSessionArray($array): array { $sessions = []; foreach ($array as $key => $item) { $session = Session::fromArray($item); $sessions[$session->getId()] = $session; } return $sessions; } }