isValid($value)) { throw new \InvalidArgumentException(\sprintf('Invalid record key "%s".', $value)); } return new RecordKey($value); } /** * Returns whether the value is a valid record key. */ public static function isValid(string $value): bool { if ($value === '' || \strlen($value) > self::MAX_LENGTH || $value === '.' || $value === '..') { return FALSE; } return \preg_match('/^[A-Za-z0-9.\-_:~]+$/', $value) === 1; } /** * Returns the normalized supplied value. */ public function normalize(string $value): string { return $this->parse($value)->value; } }