From: gggeek <giunta.gaetano@gmail.com> Date: Thu, 2 Feb 2023 15:44:03 +0000 (+0000) Subject: add new method; reduce direct usage of Value properties X-Git-Tag: 4.10.0~32 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=b90b75cb61d42cac875eb529a424f308ddca3b56;p=plcapi.git add new method; reduce direct usage of Value properties --- diff --git a/src/Encoder.php b/src/Encoder.php index 02d9f3e7..6128492b 100644 --- a/src/Encoder.php +++ b/src/Encoder.php @@ -48,8 +48,8 @@ class Encoder switch ($xmlrpcVal->kindOf()) { case 'scalar': if (in_array('extension_api', $options)) { - $val = reset($xmlrpcVal->me); - $typ = key($xmlrpcVal->me); + $val = $xmlrpcVal->scalarVal(); + $typ = $xmlrpcVal->scalarTyp(); switch ($typ) { case 'dateTime.iso8601': $xmlrpcVal = array( diff --git a/src/Response.php b/src/Response.php index f891d553..64e6373c 100644 --- a/src/Response.php +++ b/src/Response.php @@ -115,6 +115,14 @@ class Response return $this->val; } + /** + * @return string + */ + public function valueType() + { + return $this->valtyp; + } + /** * Returns an array with the cookies received from the server. * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 => $val2, ...) diff --git a/src/Value.php b/src/Value.php index 88972ca9..30a9c6b1 100644 --- a/src/Value.php +++ b/src/Value.php @@ -47,7 +47,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess /** @var Value[]|mixed */ public $me = array(); /** - * @var int + * @var int 0 for undef, 1 for scalar, 2 for array, 3 for struct * @internal */ public $mytype = 0; diff --git a/tests/08ServerTest.php b/tests/08ServerTest.php index 69068e70..07de870e 100644 --- a/tests/08ServerTest.php +++ b/tests/08ServerTest.php @@ -368,7 +368,7 @@ And turned it into nylon'; $expect_array = array('ctLeftAngleBrackets', 'ctRightAngleBrackets', 'ctAmpersands', 'ctApostrophes', 'ctQuotes'); foreach($expect_array as $val) { $b = $v->structmem($val); - $got .= $b->me['int']; + $got .= $b->scalarVal(); } $this->assertEquals($expected, $got); }