From 9f682b5465a5067f638cc9f75d4f9c891471f7e4 Mon Sep 17 00:00:00 2001 From: Steffen Lange Date: Wed, 7 Apr 2021 11:44:29 +0200 Subject: [PATCH] PatchBase: dirty adaptation of json parser for yaml files --- PatchBase.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PatchBase.php b/PatchBase.php index 657e385..9efb71e 100644 --- a/PatchBase.php +++ b/PatchBase.php @@ -46,6 +46,17 @@ abstract class PatchBase { } return false; } + protected function fetch_yaml(string $url) : bool { + $str = $this->curl($url); + if ($str) { + if (!($this->data = yaml_parse($str))) + return false; + //if ($this->array_isMulti($this->data)) + // $this->data = array_shift($this->data); + return true; + } + return false; + } protected function parse(string $re) : bool { if ($str = $this->regex_str($re)) { $this->patch->setVersion($str, true); @@ -61,6 +72,9 @@ abstract class PatchBase { } return false; } + protected function parse_yaml(string $key, string $re = '/(.*)/') : bool { + return $this->parse_json($key, $re); + } private function array_isMulti(array $arr) : bool { foreach ($arr as $val) { if (!is_array($val))