timeOut = $timeOut; $this->max = $max; } public function getTimeOut(): int { return $this->timeOut; } public function getMax(): int { return $this->max; } public static function parse(HttpHeader $header): KeepAliveHeader { $params = explode(',', $header->getFirstLine()); $timeOut = -1; $max = -1; foreach($params as $param) { if(str_starts_with($param, 'timeout=')) $timeOut = (int)substr($param, 8); elseif(str_starts_with($param, 'max=')) $max = (int)substr($param, 4); if($timeOut >= 0 && $max >= 0) break; } return new KeepAliveHeader($timeOut, $max); } }