Skip to content

PSR-4 support for #70 plus PhpDoc #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Example.php → Examples/Example.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
require __DIR__ . '/../SourceQuery/bootstrap.php';

use xPaw\SourceQuery\SourceQuery;

// For the sake of this example
Header( 'Content-Type: text/plain' );
Expand Down
4 changes: 3 additions & 1 deletion RconExample.php → Examples/RconExample.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
require __DIR__ . '/../SourceQuery/bootstrap.php';

use xPaw\SourceQuery\SourceQuery;

// For the sake of this example
Header( 'Content-Type: text/plain' );
Expand Down
6 changes: 4 additions & 2 deletions View.php → Examples/View.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
require __DIR__ . '/../SourceQuery/bootstrap.php';

use xPaw\SourceQuery\SourceQuery;

// Edit this ->
define( 'SQ_SERVER_ADDR', 'localhost' );
Expand Down Expand Up @@ -56,7 +58,7 @@
</head>

<body>
<div class="container">
<div class="container">
<div class="jumbotron">
<h1>Source Query PHP Class</h1>

Expand Down
21 changes: 16 additions & 5 deletions SourceQuery/Buffer.class.php → SourceQuery/Buffer.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
<?php
/**
* Class written by xPaw
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* Website: https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery;

/**
* Class Buffer
*
* @package xPaw\SourceQuery
*/

class SourceQueryBuffer
class Buffer
{
/**
* Buffer
Expand Down
19 changes: 19 additions & 0 deletions SourceQuery/Exception/AuthenticationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class AuthenticationException extends SourceQueryException
{
const BAD_PASSWORD = 1;
const BANNED = 2;
}
18 changes: 18 additions & 0 deletions SourceQuery/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class InvalidArgumentException extends SourceQueryException
{
const TIMEOUT_NOT_INTEGER = 1;
}
21 changes: 21 additions & 0 deletions SourceQuery/Exception/InvalidPacketException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class InvalidPacketException extends SourceQueryException
{
const PACKET_HEADER_MISMATCH = 1;
const BUFFER_EMPTY = 2;
const BUFFER_NOT_EMPTY = 3;
const CHECKSUM_MISMATCH = 4;
}
18 changes: 18 additions & 0 deletions SourceQuery/Exception/SocketException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class SocketException extends SourceQueryException
{
const COULD_NOT_CREATE_SOCKET = 1;
}
18 changes: 18 additions & 0 deletions SourceQuery/Exception/SourceQueryException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

abstract class SourceQueryException extends \Exception
{
// Base exception class
}
18 changes: 18 additions & 0 deletions SourceQuery/Exception/TimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery\Exception;

class TimeoutException extends SourceQueryException
{
const TIMEOUT_CONNECT = 1;
}
43 changes: 0 additions & 43 deletions SourceQuery/Exceptions.class.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
<?php
/**
* Class written by xPaw
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* Website: https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery;

use xPaw\SourceQuery\Exception\AuthenticationException;

class SourceQueryGoldSourceRcon

/**
* Class GoldSourceRcon
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\AuthenticationException
*/
class GoldSourceRcon
{
/**
* Points to buffer class
*
* @var SourceQueryBuffer
* @var Buffer
*/
private $Buffer;

/**
* Points to socket class
*
* @var SourceQuerySocket
* @var Socket
*/
private $Socket;

Expand Down Expand Up @@ -57,6 +70,7 @@ public function Write( $Header, $String = '' )
/**
* @param int $Length
* @throws AuthenticationException
* @return bool
*/
public function Read( $Length = 1400 )
{
Expand Down
28 changes: 21 additions & 7 deletions SourceQuery/Socket.class.php → SourceQuery/Socket.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<?php
/**
* Class written by xPaw
* @author Pavel Djundik <sourcequery@xpaw.me>
*
* Website: https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/

namespace xPaw\SourceQuery;

use xPaw\SourceQuery\Exception\InvalidPacketException;
use xPaw\SourceQuery\Exception\SocketException;

class SourceQuerySocket

/**
* Class Socket
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
* @uses xPaw\SourceQuery\Exception\SocketException
*/
class Socket
{
public $Socket;
public $Engine;
Expand All @@ -21,7 +35,7 @@ class SourceQuerySocket
/**
* Points to buffer class
*
* @var SourceQueryBuffer
* @var Buffer
*/
private $Buffer;

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

$Buffer = bzdecompress( $Buffer );
Expand Down
Loading