mirror of
https://github.com/danog/postgres.git
synced 2024-11-30 04:29:12 +01:00
Move consistency check inside generator
Each sub-array should be checked as well.
This commit is contained in:
parent
e460f50716
commit
ccce08f5f2
@ -19,10 +19,6 @@ final class ArrayParser
|
||||
{
|
||||
$data = \trim($data);
|
||||
|
||||
if ($data[0] !== '{' || \substr($data, -1) !== '}') {
|
||||
throw new ParseException("Missing opening or closing brackets");
|
||||
}
|
||||
|
||||
$parser = $this->parser($data, $cast, $delimiter);
|
||||
$data = \iterator_to_array($parser);
|
||||
|
||||
@ -46,6 +42,10 @@ final class ArrayParser
|
||||
*/
|
||||
private function parser(string $data, callable $cast = null, string $delimiter = ','): \Generator
|
||||
{
|
||||
if ($data[0] !== '{' || \substr($data, -1) !== '}') {
|
||||
throw new ParseException("Missing opening or closing brackets");
|
||||
}
|
||||
|
||||
$data = \ltrim(\substr($data, 1));
|
||||
|
||||
do {
|
||||
|
Loading…
Reference in New Issue
Block a user