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

Commit f395507

Browse files
committed
Merge branch 'release/0.1.0'
2 parents b203825 + ae9adc0 commit f395507

9 files changed

Lines changed: 316 additions & 21 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ cover
44
*.phar
55
composer.lock
66
build
7+
.idea

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ Requirements
2828
Usage
2929
-----
3030

31+
### Installation
32+
33+
Let's start by downloading composer into our project dir:
34+
```
35+
curl -O http://getcomposer.org/composer.phar
36+
chmod +x composer.phar
37+
```
38+
39+
Now let's tell composer about our project's dependancies, in this case, PHPNats. The way we do this is by creating a composer.json file, and placing it in the root folder of our project, right next to composer.phar
40+
41+
```
42+
{
43+
"require": {
44+
"repejota/nats": "master"
45+
}
46+
}
47+
```
48+
Let's let Composer work its magic:
49+
```
50+
php composer.phar install
51+
```
52+
Composer will download all the dependencies defined in composer.json, and prepare all the files needed to autoload them.
53+
54+
3155
### Basic Usage
3256

3357
```php
@@ -48,14 +72,21 @@ $client->subscribe("foo", $callback);
4872
$client->wait(1);
4973
```
5074

75+
5176
Developer's Information
5277
-----------------------
5378

79+
### Releases
80+
81+
[Latest stable](https://github.com/repejota/phpnats/tree/master)
82+
[Latest dev](https://github.com/repejota/phpnats/tree/develop)
83+
5484
### Tests
5585

5686
Tests are in the `tests` folder.
5787
To run them, you need `PHPUnit` and execute `make test`.
5888

89+
5990
### Code Quality
6091

6192
We are using [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer/docs)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.7
1+
0.1.0

src/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function isConnected()
178178
public function connect()
179179
{
180180
$this->streamSocket = $this->getStream($this->options->getAddress());
181-
$msg = 'CONNECT '.$this->options->toJSON();
181+
$msg = 'CONNECT '.$this->options;
182182
$this->send($msg);
183183
}
184184

src/ConnectionOptions.php

Lines changed: 226 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,63 @@ class ConnectionOptions
1212
*
1313
* @var string
1414
*/
15-
public $host = "localhost";
15+
private $host = "localhost";
1616

1717
/**
1818
* Port number to connect
1919
*
2020
* @var integer
2121
*/
22-
public $port = 4222;
22+
private $port = 4222;
2323

2424
/**
2525
* Username to connect
2626
*
2727
* @var string
2828
*/
29-
public $user = null;
29+
private $user = null;
3030

3131
/**
3232
* Password to connect
3333
*
3434
* @var string
3535
*/
36-
public $pass = null;
36+
private $pass = null;
3737

3838
/**
3939
* Language of this client
4040
*
4141
* @var string
4242
*/
43-
public $lang = "php";
43+
private $lang = "php";
4444

4545
/**
4646
* Version of this client
4747
*
4848
* @var string
4949
*/
50-
public $version = "0.0.5";
50+
private $version = "0.0.5";
5151

5252
/**
5353
* If verbose mode is enabled
5454
*
5555
* @var boolean
5656
*/
57-
public $verbose = false;
57+
private $verbose = false;
5858

5959
/**
6060
* If pedantic mode is enabled
6161
*
6262
* @var boolean
6363
*/
64-
public $pedantic = false;
64+
private $pedantic = false;
6565

6666
/**
6767
* If reconnect mode is enabled
6868
*
6969
* @var boolean
7070
*/
71-
public $reconnect = true;
71+
private $reconnect = true;
7272

7373
/**
7474
* Get the URI for a server
@@ -85,7 +85,7 @@ public function getAddress()
8585
*
8686
* @return string
8787
*/
88-
public function toJSON()
88+
public function __toString()
8989
{
9090
$a = [
9191
"lang" => $this->lang,
@@ -101,4 +101,220 @@ public function toJSON()
101101
}
102102
return json_encode($a);
103103
}
104+
105+
/**
106+
* Get host
107+
*
108+
* @return string
109+
*/
110+
public function getHost()
111+
{
112+
return $this->host;
113+
}
114+
115+
/**
116+
* Set host
117+
*
118+
* @param string $host Host.
119+
*
120+
* @return $this
121+
*/
122+
public function setHost($host)
123+
{
124+
$this->host = $host;
125+
126+
return $this;
127+
}
128+
129+
/**
130+
* Get port
131+
*
132+
* @return integer
133+
*/
134+
public function getPort()
135+
{
136+
return $this->port;
137+
}
138+
139+
/**
140+
* Set port
141+
*
142+
* @param integer $port Port.
143+
*
144+
* @return $this
145+
*/
146+
public function setPort($port)
147+
{
148+
$this->port = $port;
149+
150+
return $this;
151+
}
152+
153+
/**
154+
* Get user
155+
*
156+
* @return string
157+
*/
158+
public function getUser()
159+
{
160+
return $this->user;
161+
}
162+
163+
/**
164+
* Set user
165+
*
166+
* @param string $user User.
167+
*
168+
* @return $this
169+
*/
170+
public function setUser($user)
171+
{
172+
$this->user = $user;
173+
174+
return $this;
175+
}
176+
177+
/**
178+
* Get password
179+
*
180+
* @return string
181+
*/
182+
public function getPass()
183+
{
184+
return $this->pass;
185+
}
186+
187+
/**
188+
* Set password
189+
*
190+
* @param string $pass Password.
191+
*
192+
* @return $this
193+
*/
194+
public function setPass($pass)
195+
{
196+
$this->pass = $pass;
197+
198+
return $this;
199+
}
200+
201+
/**
202+
* Get language
203+
*
204+
* @return string
205+
*/
206+
public function getLang()
207+
{
208+
return $this->lang;
209+
}
210+
211+
/**
212+
* Set language
213+
*
214+
* @param string $lang Language.
215+
*
216+
* @return $this
217+
*/
218+
public function setLang($lang)
219+
{
220+
$this->lang = $lang;
221+
222+
return $this;
223+
}
224+
225+
/**
226+
* Get version
227+
*
228+
* @return string
229+
*/
230+
public function getVersion()
231+
{
232+
return $this->version;
233+
}
234+
235+
/**
236+
* Set version
237+
*
238+
* @param string $version Version number.
239+
*
240+
* @return $this
241+
*/
242+
public function setVersion($version)
243+
{
244+
$this->version = $version;
245+
246+
return $this;
247+
}
248+
249+
/**
250+
* Get verbose
251+
*
252+
* @return boolean
253+
*/
254+
public function isVerbose()
255+
{
256+
return $this->verbose;
257+
}
258+
259+
/**
260+
* Set verbose
261+
*
262+
* @param boolean $verbose Verbose flag.
263+
*
264+
* @return $this
265+
*/
266+
public function setVerbose($verbose)
267+
{
268+
$this->verbose = $verbose;
269+
270+
return $this;
271+
}
272+
273+
/**
274+
* Get pedantic
275+
*
276+
* @return boolean
277+
*/
278+
public function isPedantic()
279+
{
280+
return $this->pedantic;
281+
}
282+
283+
/**
284+
* Set pedantic
285+
*
286+
* @param boolean $pedantic Pedantic flag.
287+
*
288+
* @return $this
289+
*/
290+
public function setPedantic($pedantic)
291+
{
292+
$this->pedantic = $pedantic;
293+
294+
return $this;
295+
}
296+
297+
/**
298+
* Get reconnect
299+
*
300+
* @return boolean
301+
*/
302+
public function isReconnect()
303+
{
304+
return $this->reconnect;
305+
}
306+
307+
/**
308+
* Set reconnect
309+
*
310+
* @param boolean $reconnect Reconnect flag.
311+
*
312+
* @return $this
313+
*/
314+
public function setReconnect($reconnect)
315+
{
316+
$this->reconnect = $reconnect;
317+
318+
return $this;
319+
}
104320
}

0 commit comments

Comments
 (0)