aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/vendor/kissifrot/php-ixr/src/Request/Request.php
blob: 2664fb7a8ffa4aa53da7e791143d8c7cf2729575 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

namespace IXR\Request;

use IXR\DataType\Value;

/**
 * IXR_Request
 *
 * @package IXR
 * @since 1.5.0
 */
class Request
{
    private $method;
    private $args;
    private $xml;

    public function __construct($method, $args)
    {
        $this->method = $method;
        $this->args = $args;
        $this->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$this->method}</methodName>
<params>

EOD;
        foreach ($this->args as $arg) {
            $this->xml .= '<param><value>';
            $v = new Value($arg);
            $this->xml .= $v->getXml();
            $this->xml .= "</value></param>\n";
        }
        $this->xml .= '</params></methodCall>';
    }

    public function getLength()
    {
        return strlen($this->xml);
    }

    public function getXml()
    {
        return $this->xml;
    }
}