RemoteMethodCall::getAppName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * AppserverIo\RemoteMethodInvocation\RemoteMethodCall
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/rmi
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\RemoteMethodInvocation;
22
23
/**
24
 * The remote method call implementation.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2015 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/appserver-io/rmi
30
 * @link      http://www.appserver.io
31
 */
32
class RemoteMethodCall implements RemoteMethodInterface
33
{
34
35
    /**
36
     * The name of the webapp this call originates from
37
     *
38
     * @var string
39
     */
40
    protected $appName;
41
42
    /**
43
     * The class name to invoke the method on.
44
     *
45
     * @var string
46
     */
47
    protected $className = null;
48
49
    /**
50
     * The method name to invoke on the class.
51
     *
52
     * @var string
53
     */
54
    protected $methodName = null;
55
56
    /**
57
     * Parameters for the method.
58
     *
59
     * @var array
60
     */
61
    protected $parameters = array();
62
63
    /**
64
     * The session ID to use for the method call.
65
     *
66
     * @var string
67
     */
68
    protected $sessionId = null;
69
70
    /**
71
     * The client's socket server IP address to send the response to.
72
     *
73
     * @var string
74
     */
75
    protected $address = '127.0.0.1';
76
77
    /**
78
     * The client's socket server port to send the response to.
79
     *
80
     * @var integer
81
     */
82
    protected $port = 0;
83
84
    /**
85
     * Initialize the instance with the necessary params.
86
     *
87
     * @param string $className  The class name to invoke the method on
88
     * @param string $methodName The method name to invoke
89
     * @param string $sessionId  The session ID to use for the method call
90
     */
91 2
    public function __construct($className, $methodName, $sessionId = null)
92
    {
93 2
        $this->className = $className;
94 2
        $this->methodName = $methodName;
95 2
        $this->sessionId = $sessionId;
96 2
    }
97
98
    /**
99
     * Adds passed parameter to the array with the parameters.
100
     *
101
     * @param integer $key   The parameter name
102
     * @param mixed   $value The parameter value
103
     *
104
     * @return void
105
     */
106
    public function addParameter($key, $value)
107
    {
108
        $this->parameters[$key] = $value;
109
    }
110
111
    /**
112
     * Returns the parameter with the passed key.
113
     *
114
     * @param string $key The name of the parameter to return
115
     *
116
     * @return mixed The parameter's value
117
     * @see \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface::getParameter()
118
     */
119
    public function getParameter($key)
120
    {
121
        return $this->parameters[$key];
122
    }
123
124
    /**
125
     * Returns the parameters for the method.
126
     *
127
     * @return array The method's parameters
128
     * @see \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface::getParameters()
129
     */
130
    public function getParameters()
131
    {
132
        return $this->parameters;
133
    }
134
135
    /**
136
     * Returns the class name to invoke the method on.
137
     *
138
     * @return string The class name
139
     * @see \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface::getClassName()
140
     */
141 1
    public function getClassName()
142
    {
143 1
        return $this->className;
144
    }
145
146
    /**
147
     * Returns the method name to invoke on the class.
148
     *
149
     * @return string The method name
150
     * @see \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface::getMethodName()
151
     */
152 1
    public function getMethodName()
153
    {
154 1
        return $this->methodName;
155
    }
156
157
    /**
158
     * Returns the session ID to use for the method call.
159
     *
160
     * @return string The session ID
161
     * @see \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface::getSessionId()
162
     */
163
    public function getSessionId()
164
    {
165
        return $this->sessionId;
166
    }
167
168
    /**
169
     * Sets the client's socket server IP address.
170
     *
171
     * @param string $address The client's socket server IP address
172
     *
173
     * @return void
174
     */
175
    public function setAddress($address)
176
    {
177
        $this->address = $address;
178
    }
179
180
    /**
181
     * Returns the client's server socket IP address.
182
     *
183
     * @return string The client's server socket IP address
184
     * @see \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface::getAddress()
185
     */
186
    public function getAddress()
187
    {
188
        return $this->address;
189
    }
190
191
    /**
192
     * Sets the webapp name the call comes from
193
     *
194
     * @param string $appName Name of the webapp using this client connection
195
     *
196
     * @return void
197
     */
198
    public function setAppName($appName)
199
    {
200
        $this->appName = $appName;
201
    }
202
203
    /**
204
     * Returns the name of the webapp this call comes from
205
     *
206
     * @return string The webapp name
207
     */
208
    public function getAppName()
209
    {
210
        return $this->appName;
211
    }
212
213
    /**
214
     * Sets the client's socket server port.
215
     *
216
     * @param integer $port The client's socket server port
217
     *
218
     * @return void
219
     */
220
    public function setPort($port)
221
    {
222
        $this->port = $port;
223
    }
224
225
    /**
226
     * Returns the client's server socket port.
227
     *
228
     * @return string The client's server socket port
229
     * @see \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface::getPort()
230
     */
231
    public function getPort()
232
    {
233
        return $this->port;
234
    }
235
}
236