Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 7d80efb

Browse files
author
Raül Pérez
committed
Merge branch 'release/0.0.6'
2 parents 98e99fa + 9b2e1f2 commit 7d80efb

12 files changed

Lines changed: 137 additions & 149 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cs: lint
22
./vendor/bin/phpcbf --standard=PSR2 src tests examples
33
./vendor/bin/phpcs --standard=PSR2 --warning-severity=0 src tests examples
4+
./vendor/bin/phpcs --standard=Squiz --sniffs=Squiz.Commenting.FunctionComment,Squiz.Commenting.FunctionCommentThrowTag,Squiz.Commenting.ClassComment,Squiz.Commenting.VariableComment src tests examples
45

56
test:
67
./vendor/bin/phpunit

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.5
1+
0.0.6

examples/authconnect.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
<?php
2-
/**
3-
* Connection example
4-
*
5-
* PHP version 5
6-
*
7-
* @category Script
8-
* @package Nats
9-
* @author Raül Përez <repejota@gmail.com>
10-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
11-
* @link https://github.com/repejota/phpnats
12-
*/
132
require_once "../vendor/autoload.php";
143

154
$c = new Nats\Connection();

examples/connect.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
<?php
2-
/**
3-
* Connection example
4-
*
5-
* PHP version 5
6-
*
7-
* @category Script
8-
* @package Nats
9-
* @author Raül Përez <repejota@gmail.com>
10-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
11-
* @link https://github.com/repejota/phpnats
12-
*/
132
require_once "../vendor/autoload.php";
143

154
$c = new Nats\Connection();

examples/ping.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
<?php
2-
/**
3-
* PING example
4-
*
5-
* PHP version 5
6-
*
7-
* @category Script
8-
* @package Nats
9-
* @author Raül Përez <repejota@gmail.com>
10-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
11-
* @link https://github.com/repejota/phpnats
12-
*/
132
require_once "../vendor/autoload.php";
143

154
const HOST = "localhost";

examples/pubsub/pub.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
<?php
2-
/**
3-
* Publisher example
4-
*
5-
* PHP version 5
6-
*
7-
* @category Script
8-
* @package Nats
9-
* @author Raül Përez <repejota@gmail.com>
10-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
11-
* @link https://github.com/repejota/phpnats
12-
*/
132
require_once "../../vendor/autoload.php";
143

154
const HOST = "localhost";

examples/pubsub/sub.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
<?php
2-
/**
3-
* Subscriber example
4-
*
5-
* PHP version 5
6-
*
7-
* @category Script
8-
* @package Nats
9-
* @author Raül Përez <repejota@gmail.com>
10-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
11-
* @link https://github.com/repejota/phpnats
12-
*/
132
require_once "../../vendor/autoload.php";
143

154
const HOST = "localhost";

src/Connection.php

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
<?php
2-
3-
/**
4-
* Connection Class.
5-
*
6-
* PHP version 5
7-
*
8-
* @category Class
9-
*
10-
* @author Raül Përez <repejota@gmail.com>
11-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
12-
*
13-
* @link https://github.com/repejota/phpnats
14-
*/
15-
162
namespace Nats;
173

184
/**
195
* Connection Class.
20-
*
21-
* @category Class
22-
*
23-
* @author Raül Përez <repejota@gmail.com>
24-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
25-
*
26-
* @link https://github.com/repejota/phpnats
276
*/
287
class Connection
298
{
@@ -105,6 +84,11 @@ public function getSubscriptions()
10584
return array_keys($this->subscriptions);
10685
}
10786

87+
/**
88+
* Connection options object
89+
*
90+
* @var ConnectionOptions|null
91+
*/
10892
private $options = null;
10993

11094
/**
@@ -117,8 +101,7 @@ public function getSubscriptions()
117101
/**
118102
* Constructor.
119103
*
120-
* @param string $host name, by default "localhost"
121-
* @param int $port number, by default 4222
104+
* @param ConnectionOptions $options Connection options object.
122105
*/
123106
public function __construct(ConnectionOptions $options = null)
124107
{
@@ -135,7 +118,8 @@ public function __construct(ConnectionOptions $options = null)
135118
/**
136119
* Sends data thought the stream.
137120
*
138-
* @param string $payload message data
121+
* @param string $payload Message data.
122+
* @return void
139123
*/
140124
private function send($payload)
141125
{
@@ -146,7 +130,7 @@ private function send($payload)
146130
/**
147131
* Receives a message thought the stream.
148132
*
149-
* @param int $len Number of bytes to receive
133+
* @param integer $len Number of bytes to receive.
150134
*
151135
* @return string
152136
*/
@@ -162,7 +146,7 @@ private function receive($len = null)
162146
/**
163147
* Returns an stream socket to the desired server.
164148
*
165-
* @param string $address Server url string
149+
* @param string $address Server url string.
166150
*
167151
* @return resource
168152
*/
@@ -179,7 +163,7 @@ private function getStream($address)
179163
/**
180164
* Checks if the client is connected to a server.
181165
*
182-
* @return bool
166+
* @return boolean
183167
*/
184168
public function isConnected()
185169
{
@@ -188,6 +172,8 @@ public function isConnected()
188172

189173
/**
190174
* Connect to server.
175+
*
176+
* @return void
191177
*/
192178
public function connect()
193179
{
@@ -198,6 +184,8 @@ public function connect()
198184

199185
/**
200186
* Sends PING message.
187+
*
188+
* @return void
201189
*/
202190
public function ping()
203191
{
@@ -209,10 +197,9 @@ public function ping()
209197
/**
210198
* Publish publishes the data argument to the given subject.
211199
*
212-
* @param string $subject message topic
213-
* @param string $payload message data
214-
*
215-
* @return string
200+
* @param string $subject Message topic.
201+
* @param string $payload Message data.
202+
* @return void
216203
*/
217204
public function publish($subject, $payload)
218205
{
@@ -225,9 +212,8 @@ public function publish($subject, $payload)
225212
/**
226213
* Subscribes to an specific event given a subject.
227214
*
228-
* @param string $subject message topic
229-
* @param mixed $callback closure to be executed as callback
230-
*
215+
* @param string $subject Message topic.
216+
* @param resource $callback Closure to be executed as callback.
231217
* @return string
232218
*/
233219
public function subscribe($subject, $callback)
@@ -243,7 +229,8 @@ public function subscribe($subject, $callback)
243229
/**
244230
* Unsubscribe from a event given a subject.
245231
*
246-
* @param string $sid Subscription ID
232+
* @param string $sid Subscription ID.
233+
* @return void
247234
*/
248235
public function unsubscribe($sid)
249236
{
@@ -253,6 +240,8 @@ public function unsubscribe($sid)
253240

254241
/**
255242
* Handles PING command.
243+
*
244+
* @return void
256245
*/
257246
private function handlePING()
258247
{
@@ -262,7 +251,7 @@ private function handlePING()
262251
/**
263252
* Handles MSG command.
264253
*
265-
* @param string $line Message command from NATS
254+
* @param string $line Message command from NATS.
266255
*
267256
* @return \Exception|void
268257
*/
@@ -287,9 +276,8 @@ private function handleMSG($line)
287276
/**
288277
* Waits for messages.
289278
*
290-
* @param int $quantity Number of messages to wait for
291-
*
292-
* @return \Exception|void
279+
* @param integer $quantity Number of messages to wait for.
280+
* @return resource $connection Connection object
293281
*/
294282
public function wait($quantity = 0)
295283
{
@@ -307,7 +295,7 @@ public function wait($quantity = 0)
307295
$count = $count + 1;
308296
$this->handleMSG($line);
309297
if (($quantity != 0) && ($count >= $quantity)) {
310-
return;
298+
return $this;
311299
}
312300
}
313301
}
@@ -318,6 +306,8 @@ public function wait($quantity = 0)
318306

319307
/**
320308
* Reconnects to the server.
309+
*
310+
* @return void
321311
*/
322312
public function reconnect()
323313
{
@@ -328,6 +318,8 @@ public function reconnect()
328318

329319
/**
330320
* Close will close the connection to the server.
321+
*
322+
* @return void
331323
*/
332324
public function close()
333325
{

src/ConnectionOptions.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
<?php
2-
/**
3-
* ConnectionOptions Class
4-
*
5-
* PHP version 5
6-
*
7-
* @category Class
8-
* @package Nats
9-
* @author Raül Përez <repejota@gmail.com>
10-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
11-
* @link https://github.com/repejota/phpnats
12-
*/
132
namespace Nats;
143

154
/**
165
* ConnectionOptions Class
17-
*
18-
* @category Class
19-
* @package Nats\Tests\Unit
20-
* @author Raül Përez <repejota@gmail.com>
21-
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
22-
* @link https://github.com/repejota/phpnats
236
*/
247
class ConnectionOptions
258
{
@@ -34,7 +17,7 @@ class ConnectionOptions
3417
/**
3518
* Port number to connect
3619
*
37-
* @var int
20+
* @var integer
3821
*/
3922
public $port = 4222;
4023

@@ -69,21 +52,21 @@ class ConnectionOptions
6952
/**
7053
* If verbose mode is enabled
7154
*
72-
* @var bool
55+
* @var boolean
7356
*/
7457
public $verbose = false;
7558

7659
/**
7760
* If pedantic mode is enabled
7861
*
79-
* @var bool
62+
* @var boolean
8063
*/
8164
public $pedantic = false;
8265

8366
/**
8467
* If reconnect mode is enabled
8568
*
86-
* @var bool
69+
* @var boolean
8770
*/
8871
public $reconnect = true;
8972

0 commit comments

Comments
 (0)