xref: /dokuwiki/vendor/kissifrot/php-ixr/src/Request/Request.php (revision 7f8f24562b596c56d79e46eba9f82780df5725cb)
1*7f8f2456SAndreas Gohr<?php
2*7f8f2456SAndreas Gohr
3*7f8f2456SAndreas Gohrnamespace IXR\Request;
4*7f8f2456SAndreas Gohr
5*7f8f2456SAndreas Gohruse IXR\DataType\Value;
6*7f8f2456SAndreas Gohr
7*7f8f2456SAndreas Gohr/**
8*7f8f2456SAndreas Gohr * IXR_Request
9*7f8f2456SAndreas Gohr *
10*7f8f2456SAndreas Gohr * @package IXR
11*7f8f2456SAndreas Gohr * @since 1.5.0
12*7f8f2456SAndreas Gohr */
13*7f8f2456SAndreas Gohrclass Request
14*7f8f2456SAndreas Gohr{
15*7f8f2456SAndreas Gohr    private $method;
16*7f8f2456SAndreas Gohr    private $args;
17*7f8f2456SAndreas Gohr    private $xml;
18*7f8f2456SAndreas Gohr
19*7f8f2456SAndreas Gohr    public function __construct($method, $args)
20*7f8f2456SAndreas Gohr    {
21*7f8f2456SAndreas Gohr        $this->method = $method;
22*7f8f2456SAndreas Gohr        $this->args = $args;
23*7f8f2456SAndreas Gohr        $this->xml = <<<EOD
24*7f8f2456SAndreas Gohr<?xml version="1.0"?>
25*7f8f2456SAndreas Gohr<methodCall>
26*7f8f2456SAndreas Gohr<methodName>{$this->method}</methodName>
27*7f8f2456SAndreas Gohr<params>
28*7f8f2456SAndreas Gohr
29*7f8f2456SAndreas GohrEOD;
30*7f8f2456SAndreas Gohr        foreach ($this->args as $arg) {
31*7f8f2456SAndreas Gohr            $this->xml .= '<param><value>';
32*7f8f2456SAndreas Gohr            $v = new Value($arg);
33*7f8f2456SAndreas Gohr            $this->xml .= $v->getXml();
34*7f8f2456SAndreas Gohr            $this->xml .= "</value></param>\n";
35*7f8f2456SAndreas Gohr        }
36*7f8f2456SAndreas Gohr        $this->xml .= '</params></methodCall>';
37*7f8f2456SAndreas Gohr    }
38*7f8f2456SAndreas Gohr
39*7f8f2456SAndreas Gohr    public function getLength()
40*7f8f2456SAndreas Gohr    {
41*7f8f2456SAndreas Gohr        return strlen($this->xml);
42*7f8f2456SAndreas Gohr    }
43*7f8f2456SAndreas Gohr
44*7f8f2456SAndreas Gohr    public function getXml()
45*7f8f2456SAndreas Gohr    {
46*7f8f2456SAndreas Gohr        return $this->xml;
47*7f8f2456SAndreas Gohr    }
48*7f8f2456SAndreas Gohr}
49