Skip to content

Commit

Permalink
fix: assert type string is matched
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Oct 9, 2024
1 parent 7847029 commit 55a5469
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Sql/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace SimPod\ClickHouseClient\Sql;

use function assert;
use function preg_match;

final readonly class Type
Expand All @@ -14,7 +15,8 @@ private function __construct(public string $name, public string $params)

public static function fromString(string $type): self
{
preg_match('~([a-zA-Z\d ]+)(?:\((.+)\))?~', $type, $matches);
$result = preg_match('~([a-zA-Z\d ]+)(?:\((.+)\))?~', $type, $matches);
assert($result === 1);

return new self($matches[1], $matches[2] ?? '');
}
Expand Down

0 comments on commit 55a5469

Please sign in to comment.