1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-26 12:04:50 +01:00

Move consistency check inside generator

Each sub-array should be checked as well.
This commit is contained in:
Aaron Piotrowski 2019-03-26 11:20:03 -05:00
parent e460f50716
commit ccce08f5f2
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -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 {