Add RegEx filter to JSON parsing
This commit is contained in:
parent
ae0b34362e
commit
a88cf9235e
1 changed files with 4 additions and 4 deletions
|
|
@ -34,16 +34,16 @@ abstract class PatchBase {
|
||||||
}
|
}
|
||||||
protected function parse(string $re) : bool {
|
protected function parse(string $re) : bool {
|
||||||
if ($str = $this->regex_str($re)) {
|
if ($str = $this->regex_str($re)) {
|
||||||
$this->patch->setVersion($str);
|
$this->patch->setVersion($str, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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)));
|
$flat = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data)));
|
||||||
if (!empty($flat[$key])) {
|
if (!empty($flat[$key])) {
|
||||||
$this->patch->setVersion($flat[$key], true);
|
$this->data = $flat[$key];
|
||||||
return true;
|
return $this->parse($re);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue