From a88cf9235e076d37c169a49d6ddb55192b8bf564 Mon Sep 17 00:00:00 2001 From: Steffen Lange Date: Fri, 9 Oct 2020 21:34:02 +0200 Subject: [PATCH] Add RegEx filter to JSON parsing --- PatchBase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PatchBase.php b/PatchBase.php index 0f56b5b..384e313 100644 --- a/PatchBase.php +++ b/PatchBase.php @@ -34,16 +34,16 @@ abstract class PatchBase { } protected function parse(string $re) : bool { if ($str = $this->regex_str($re)) { - $this->patch->setVersion($str); + $this->patch->setVersion($str, true); return true; } return false; } - protected function parse_json(string $key) : bool { + protected function parse_json(string $key, string $re = '/(.*)/') : bool { $flat = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data))); if (!empty($flat[$key])) { - $this->patch->setVersion($flat[$key], true); - return true; + $this->data = $flat[$key]; + return $this->parse($re); } return false; }