add new method; reduce direct usage of Value properties
authorgggeek <giunta.gaetano@gmail.com>
Thu, 2 Feb 2023 15:44:03 +0000 (15:44 +0000)
committergggeek <giunta.gaetano@gmail.com>
Thu, 2 Feb 2023 15:44:03 +0000 (15:44 +0000)
src/Encoder.php
src/Response.php
src/Value.php
tests/08ServerTest.php

index 02d9f3e..6128492 100644 (file)
@@ -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(
index f891d55..64e6373 100644 (file)
@@ -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, ...)
index 88972ca..30a9c6b 100644 (file)
@@ -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;
index 69068e7..07de870 100644 (file)
@@ -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);
         }