Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Commit 558ef40

Browse files
author
Pascal Krason
committed
Corrected Syntax from #8
1 parent 2ddf7b3 commit 558ef40

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/Client.php

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class Client
2626
* JSONRPC User Name
2727
* @var string
2828
*/
29-
private $user = '';
29+
private $username = null;
3030

3131
/**
3232
* JSONRPC Password
3333
* @var string
3434
*/
35-
private $pass = '';
35+
private $password = null;
3636

3737
/**
3838
* Last Message-ID
@@ -44,21 +44,21 @@ class Client
4444
* @param string $host
4545
* @param int $port
4646
* @param int $id
47-
* @param string $user
47+
* @param string $username
4848
* @param string $password
4949
*/
5050
public function __construct(
5151
$host = 'http://127.0.0.1',
5252
$port = 7777,
5353
$id = 0,
54-
$user = null,
54+
$username = null,
5555
$password = null
5656
) {
5757
$this->setHost($host);
5858
$this->setPort($port);
59-
$this->setUserName($user);
60-
$this->setPassword($password);
6159
$this->setId($id);
60+
$this->setUsername($username);
61+
$this->setPassword($password);
6262
}
6363

6464
/**
@@ -133,9 +133,9 @@ private function executeCurlRequest($request)
133133
]);
134134

135135
// Authorization
136-
if ($this->user || $this->pass) {
136+
if ($this->getUsername() && $this->getPassword()) {
137137
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
138-
curl_setopt($curl, CURLOPT_USERPWD, $this->user . ":" . $this->pass);
138+
curl_setopt($curl, CURLOPT_USERPWD, $this->getUsername() . ":" . $this->getPassword());
139139
}
140140

141141
// Execute request & convert data to array
@@ -166,7 +166,7 @@ public function getHost()
166166
/**
167167
* @param string $host
168168
*
169-
* @return Request
169+
* @return Client
170170
*/
171171
public function setHost($host)
172172
{
@@ -186,7 +186,7 @@ public function getPort()
186186
/**
187187
* @param int $port
188188
*
189-
* @return Request
189+
* @return Client
190190
*/
191191
public function setPort($port)
192192
{
@@ -198,20 +198,19 @@ public function setPort($port)
198198
/**
199199
* @return string
200200
*/
201-
public function getUserName()
201+
public function getUsername()
202202
{
203-
return $this->user;
203+
return $this->username;
204204
}
205205

206206
/**
207-
* @param $value
208-
*
209-
* @return Request
207+
* @param string $username
210208
*
209+
* @return Client
211210
*/
212-
public function setUserName($value)
211+
public function setUsername($username)
213212
{
214-
$this->user = $value;
213+
$this->username = $username;
215214

216215
return $this;
217216
}
@@ -221,18 +220,17 @@ public function setUserName($value)
221220
*/
222221
public function getPassword()
223222
{
224-
return $this->pass;
223+
return $this->password;
225224
}
226225

227226
/**
228-
* @param $value
229-
*
230-
* @return Request
227+
* @param string $password
231228
*
229+
* @return Client
232230
*/
233-
public function setPassword($value)
231+
public function setPassword($password)
234232
{
235-
$this->pass = $value;
233+
$this->password = $password;
236234

237235
return $this;
238236
}
@@ -256,7 +254,7 @@ public function getNextId()
256254
/**
257255
* @param int $id
258256
*
259-
* @return Request
257+
* @return Client
260258
*/
261259
public function setId($id)
262260
{

0 commit comments

Comments
 (0)