Skip to content

Commit e570cf7

Browse files
committed
Merge pull request #72 from timmw/master
PSR-4 support for #70 plus PhpDoc
2 parents a0f07fa + 9af9cf4 commit e570cf7

17 files changed

+259
-98
lines changed

Example.php renamed to Examples/Example.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
2-
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
2+
require __DIR__ . '/../SourceQuery/bootstrap.php';
3+
4+
use xPaw\SourceQuery\SourceQuery;
35

46
// For the sake of this example
57
Header( 'Content-Type: text/plain' );

RconExample.php renamed to Examples/RconExample.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
2-
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
2+
require __DIR__ . '/../SourceQuery/bootstrap.php';
3+
4+
use xPaw\SourceQuery\SourceQuery;
35

46
// For the sake of this example
57
Header( 'Content-Type: text/plain' );

View.php renamed to Examples/View.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
2-
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
2+
require __DIR__ . '/../SourceQuery/bootstrap.php';
3+
4+
use xPaw\SourceQuery\SourceQuery;
35

46
// Edit this ->
57
define( 'SQ_SERVER_ADDR', 'localhost' );
@@ -56,7 +58,7 @@
5658
</head>
5759

5860
<body>
59-
<div class="container">
61+
<div class="container">
6062
<div class="jumbotron">
6163
<h1>Source Query PHP Class</h1>
6264

SourceQuery/Buffer.class.php renamed to SourceQuery/Buffer.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
<?php
22
/**
3-
* Class written by xPaw
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
44
*
5-
* Website: https://xpaw.me
6-
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
11+
*/
12+
13+
namespace xPaw\SourceQuery;
14+
15+
/**
16+
* Class Buffer
17+
*
18+
* @package xPaw\SourceQuery
719
*/
8-
9-
class SourceQueryBuffer
20+
class Buffer
1021
{
1122
/**
1223
* Buffer
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
4+
*
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
11+
*/
12+
13+
namespace xPaw\SourceQuery\Exception;
14+
15+
class AuthenticationException extends SourceQueryException
16+
{
17+
const BAD_PASSWORD = 1;
18+
const BANNED = 2;
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
4+
*
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
11+
*/
12+
13+
namespace xPaw\SourceQuery\Exception;
14+
15+
class InvalidArgumentException extends SourceQueryException
16+
{
17+
const TIMEOUT_NOT_INTEGER = 1;
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
4+
*
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
11+
*/
12+
13+
namespace xPaw\SourceQuery\Exception;
14+
15+
class InvalidPacketException extends SourceQueryException
16+
{
17+
const PACKET_HEADER_MISMATCH = 1;
18+
const BUFFER_EMPTY = 2;
19+
const BUFFER_NOT_EMPTY = 3;
20+
const CHECKSUM_MISMATCH = 4;
21+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
4+
*
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
11+
*/
12+
13+
namespace xPaw\SourceQuery\Exception;
14+
15+
class SocketException extends SourceQueryException
16+
{
17+
const COULD_NOT_CREATE_SOCKET = 1;
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
4+
*
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
11+
*/
12+
13+
namespace xPaw\SourceQuery\Exception;
14+
15+
abstract class SourceQueryException extends \Exception
16+
{
17+
// Base exception class
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
4+
*
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
11+
*/
12+
13+
namespace xPaw\SourceQuery\Exception;
14+
15+
class TimeoutException extends SourceQueryException
16+
{
17+
const TIMEOUT_CONNECT = 1;
18+
}

SourceQuery/Exceptions.class.php

Lines changed: 0 additions & 43 deletions
This file was deleted.

SourceQuery/GoldSourceRcon.class.php renamed to SourceQuery/GoldSourceRcon.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
<?php
22
/**
3-
* Class written by xPaw
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
44
*
5-
* Website: https://xpaw.me
6-
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
711
*/
12+
13+
namespace xPaw\SourceQuery;
814

915
use xPaw\SourceQuery\Exception\AuthenticationException;
10-
11-
class SourceQueryGoldSourceRcon
16+
17+
/**
18+
* Class GoldSourceRcon
19+
*
20+
* @package xPaw\SourceQuery
21+
*
22+
* @uses xPaw\SourceQuery\Exception\AuthenticationException
23+
*/
24+
class GoldSourceRcon
1225
{
1326
/**
1427
* Points to buffer class
1528
*
16-
* @var SourceQueryBuffer
29+
* @var Buffer
1730
*/
1831
private $Buffer;
1932

2033
/**
2134
* Points to socket class
2235
*
23-
* @var SourceQuerySocket
36+
* @var Socket
2437
*/
2538
private $Socket;
2639

@@ -57,6 +70,7 @@ public function Write( $Header, $String = '' )
5770
/**
5871
* @param int $Length
5972
* @throws AuthenticationException
73+
* @return bool
6074
*/
6175
public function Read( $Length = 1400 )
6276
{

SourceQuery/Socket.class.php renamed to SourceQuery/Socket.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
<?php
22
/**
3-
* Class written by xPaw
3+
* @author Pavel Djundik <sourcequery@xpaw.me>
44
*
5-
* Website: https://xpaw.me
6-
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
5+
* @link https://xpaw.me
6+
* @link https://github.com/xPaw/PHP-Source-Query-Class
7+
*
8+
* @license GNU Lesser General Public License, version 2.1
9+
*
10+
* @internal
711
*/
12+
13+
namespace xPaw\SourceQuery;
814

915
use xPaw\SourceQuery\Exception\InvalidPacketException;
1016
use xPaw\SourceQuery\Exception\SocketException;
11-
12-
class SourceQuerySocket
17+
18+
/**
19+
* Class Socket
20+
*
21+
* @package xPaw\SourceQuery
22+
*
23+
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
24+
* @uses xPaw\SourceQuery\Exception\SocketException
25+
*/
26+
class Socket
1327
{
1428
public $Socket;
1529
public $Engine;
@@ -21,7 +35,7 @@ class SourceQuerySocket
2135
/**
2236
* Points to buffer class
2337
*
24-
* @var SourceQueryBuffer
38+
* @var Buffer
2539
*/
2640
private $Buffer;
2741

@@ -144,7 +158,7 @@ protected function ReadBuffer( $Buffer, $Length )
144158
// Let's make sure this function exists, it's not included in PHP by default
145159
if( !Function_Exists( 'bzdecompress' ) )
146160
{
147-
throw new RuntimeException( 'Received compressed packet, PHP doesn\'t have Bzip2 library installed, can\'t decompress.' );
161+
throw new \RuntimeException( 'Received compressed packet, PHP doesn\'t have Bzip2 library installed, can\'t decompress.' );
148162
}
149163

150164
$Buffer = bzdecompress( $Buffer );

0 commit comments

Comments
 (0)