value !== $key) { throw new SyntaxError('No valid http value key could be extracted from "'.$httpValue.'".'); } return $instance; } public static function tryFrom(Stringable|string|int $httpValue): ?self { try { return self::from($httpValue); } catch (SyntaxError $e) { return null; } } /** * @throws SyntaxError If the string does not start with a valid HTTP value field key */ public static function fromStringBeginning(string $httpValue): self { if (1 !== preg_match('/^(?[a-z*][a-z\d.*_-]*)/', $httpValue, $found)) { throw new SyntaxError('No valid http value key could be extracted from "'.$httpValue.'".'); } return new self($found['key']); } }