godType = $godType; $this->status = $status; $this->expireTime = $expireTime; $this->duration = $duration; $this->updatedAt = $updatedAt; } /** * 从数组创建DTO对象 * * @param array $data 数组数据 * @return self */ public static function fromArray(array $data): self { return new self( $data['god_type'], $data['status'], $data['expire_time'] ?? null, $data['duration'], $data['updated_at'] ); } /** * 转换为数组 * * @return array */ public function toArray(): array { return [ 'god_type' => $this->godType, 'status' => $this->status, 'expire_time' => $this->expireTime, 'duration' => $this->duration, 'updated_at' => $this->updatedAt, ]; } }