PSR-4 support for #70 plus PhpDoc

pull/72/head
Tim 9 years ago
parent a0f07fa801
commit 9af9cf4f6b

@ -1,5 +1,7 @@
<?php <?php
require __DIR__ . '/SourceQuery/SourceQuery.class.php'; require __DIR__ . '/../SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
// For the sake of this example // For the sake of this example
Header( 'Content-Type: text/plain' ); Header( 'Content-Type: text/plain' );

@ -1,5 +1,7 @@
<?php <?php
require __DIR__ . '/SourceQuery/SourceQuery.class.php'; require __DIR__ . '/../SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
// For the sake of this example // For the sake of this example
Header( 'Content-Type: text/plain' ); Header( 'Content-Type: text/plain' );

@ -1,5 +1,7 @@
<?php <?php
require __DIR__ . '/SourceQuery/SourceQuery.class.php'; require __DIR__ . '/../SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
// Edit this -> // Edit this ->
define( 'SQ_SERVER_ADDR', 'localhost' ); define( 'SQ_SERVER_ADDR', 'localhost' );
@ -56,7 +58,7 @@
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="jumbotron"> <div class="jumbotron">
<h1>Source Query PHP Class</h1> <h1>Source Query PHP Class</h1>

@ -1,12 +1,23 @@
<?php <?php
/** /**
* Class written by xPaw * @author Pavel Djundik <sourcequery@xpaw.me>
* *
* Website: https://xpaw.me * @link https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class * @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 Buffer
class SourceQueryBuffer
{ {
/** /**
* Buffer * Buffer

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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
}

@ -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;
}

@ -1,43 +0,0 @@
<?php
/**
* Class written by xPaw
*
* Website: https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
*/
namespace xPaw\SourceQuery\Exception;
abstract class SourceQueryException extends \Exception
{
// Base exception class
}
class InvalidArgumentException extends SourceQueryException
{
const TIMEOUT_NOT_INTEGER = 1;
}
class TimeoutException extends SourceQueryException
{
const TIMEOUT_CONNECT = 1;
}
class InvalidPacketException extends SourceQueryException
{
const PACKET_HEADER_MISMATCH = 1;
const BUFFER_EMPTY = 2;
const BUFFER_NOT_EMPTY = 3;
const CHECKSUM_MISMATCH = 4;
}
class AuthenticationException extends SourceQueryException
{
const BAD_PASSWORD = 1;
const BANNED = 2;
}
class SocketException extends SourceQueryException
{
const COULD_NOT_CREATE_SOCKET = 1;
}

@ -1,26 +1,39 @@
<?php <?php
/** /**
* Class written by xPaw * @author Pavel Djundik <sourcequery@xpaw.me>
* *
* Website: https://xpaw.me * @link https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class * @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; use xPaw\SourceQuery\Exception\AuthenticationException;
class SourceQueryGoldSourceRcon /**
* Class GoldSourceRcon
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\AuthenticationException
*/
class GoldSourceRcon
{ {
/** /**
* Points to buffer class * Points to buffer class
* *
* @var SourceQueryBuffer * @var Buffer
*/ */
private $Buffer; private $Buffer;
/** /**
* Points to socket class * Points to socket class
* *
* @var SourceQuerySocket * @var Socket
*/ */
private $Socket; private $Socket;
@ -57,6 +70,7 @@
/** /**
* @param int $Length * @param int $Length
* @throws AuthenticationException * @throws AuthenticationException
* @return bool
*/ */
public function Read( $Length = 1400 ) public function Read( $Length = 1400 )
{ {

@ -1,15 +1,29 @@
<?php <?php
/** /**
* Class written by xPaw * @author Pavel Djundik <sourcequery@xpaw.me>
* *
* Website: https://xpaw.me * @link https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class * @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\InvalidPacketException;
use xPaw\SourceQuery\Exception\SocketException; 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 $Socket;
public $Engine; public $Engine;
@ -21,7 +35,7 @@
/** /**
* Points to buffer class * Points to buffer class
* *
* @var SourceQueryBuffer * @var Buffer
*/ */
private $Buffer; private $Buffer;
@ -144,7 +158,7 @@
// Let's make sure this function exists, it's not included in PHP by default // Let's make sure this function exists, it's not included in PHP by default
if( !Function_Exists( 'bzdecompress' ) ) 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 ); $Buffer = bzdecompress( $Buffer );

@ -1,30 +1,36 @@
<?php <?php
/** /**
* Class written by xPaw * This class provides the public interface to the PHP-Source-Query library.
* *
* Website: https://xpaw.me * @author Pavel Djundik <sourcequery@xpaw.me>
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
* *
* Special thanks to koraktor for his awesome Steam Condenser class, * @link https://xpaw.me
* I used it as a reference at some points. * @link https://github.com/xPaw/PHP-Source-Query-Class
*
* @license GNU Lesser General Public License, version 2.1
*/ */
require __DIR__ . '/Exceptions.class.php'; namespace xPaw\SourceQuery;
require __DIR__ . '/Buffer.class.php';
require __DIR__ . '/Socket.class.php';
require __DIR__ . '/SourceRcon.class.php';
require __DIR__ . '/GoldSourceRcon.class.php';
use xPaw\SourceQuery\Exception\InvalidArgumentException; use xPaw\SourceQuery\Exception\InvalidArgumentException;
use xPaw\SourceQuery\Exception\TimeoutException; use xPaw\SourceQuery\Exception\TimeoutException;
use xPaw\SourceQuery\Exception\InvalidPacketException; use xPaw\SourceQuery\Exception\InvalidPacketException;
/**
* Class SourceQuery
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\InvalidArgumentException
* @uses xPaw\SourceQuery\Exception\TimeoutException
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
*/
class SourceQuery class SourceQuery
{ {
/** /**
* Values returned by GetChallenge() * Values returned by GetChallenge()
* *
* TODO: Get rid of this? Improve? Do something else? * @todo Get rid of this? Improve? Do something else?
*/ */
const GETCHALLENGE_FAILED = 0; const GETCHALLENGE_FAILED = 0;
const GETCHALLENGE_ALL_CLEAR = 1; const GETCHALLENGE_ALL_CLEAR = 1;
@ -71,21 +77,21 @@
/** /**
* Points to rcon class * Points to rcon class
* *
* @var SourceQueryRcon * @var SourceRcon
*/ */
private $Rcon; private $Rcon;
/** /**
* Points to buffer class * Points to buffer class
* *
* @var SourceQueryBuffer * @var Buffer
*/ */
private $Buffer; private $Buffer;
/** /**
* Points to socket class * Points to socket class
* *
* @var SourceQuerySocket * @var Socket
*/ */
private $Socket; private $Socket;
@ -112,8 +118,8 @@
public function __construct( ) public function __construct( )
{ {
$this->Buffer = new SourceQueryBuffer( ); $this->Buffer = new Buffer( );
$this->Socket = new SourceQuerySocket( $this->Buffer ); $this->Socket = new Socket( $this->Buffer );
} }
public function __destruct( ) public function __destruct( )
@ -530,13 +536,13 @@
{ {
case SourceQuery :: GOLDSOURCE: case SourceQuery :: GOLDSOURCE:
{ {
$this->Rcon = new SourceQueryGoldSourceRcon( $this->Buffer, $this->Socket ); $this->Rcon = new GoldSourceRcon( $this->Buffer, $this->Socket );
break; break;
} }
case SourceQuery :: SOURCE: case SourceQuery :: SOURCE:
{ {
$this->Rcon = new SourceQuerySourceRcon( $this->Buffer, $this->Socket ); $this->Rcon = new SourceRcon( $this->Buffer, $this->Socket );
break; break;
} }

@ -1,28 +1,43 @@
<?php <?php
/** /**
* Class written by xPaw * @author Pavel Djundik <sourcequery@xpaw.me>
* *
* Website: https://xpaw.me * @link https://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class * @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; use xPaw\SourceQuery\Exception\AuthenticationException;
use xPaw\SourceQuery\Exception\TimeoutException; use xPaw\SourceQuery\Exception\TimeoutException;
use xPaw\SourceQuery\Exception\InvalidPacketException; use xPaw\SourceQuery\Exception\InvalidPacketException;
class SourceQuerySourceRcon /**
* Class SourceRcon
*
* @package xPaw\SourceQuery
*
* @uses xPaw\SourceQuery\Exception\AuthenticationException
* @uses xPaw\SourceQuery\Exception\TimeoutException
* @uses xPaw\SourceQuery\Exception\InvalidPacketException
*/
class SourceRcon
{ {
/** /**
* Points to buffer class * Points to buffer class
* *
* @var SourceQueryBuffer * @var Buffer
*/ */
private $Buffer; private $Buffer;
/** /**
* Points to socket class * Points to socket class
* *
* @var SourceQuerySocket * @var Socket
*/ */
private $Socket; private $Socket;

@ -0,0 +1,27 @@
<?php
/**
* Library to query servers that implement Source Engine Query protocol.
*
* Special thanks to koraktor for his awesome Steam Condenser class,
* I used it as a reference at some points.
*
* @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
*/
require_once __DIR__ . '/Exception/SourceQueryException.php';
require_once __DIR__ . '/Exception/AuthenticationException.php';
require_once __DIR__ . '/Exception/InvalidArgumentException.php';
require_once __DIR__ . '/Exception/SocketException.php';
require_once __DIR__ . '/Exception/InvalidPacketException.php';
require_once __DIR__ . '/Exception/TimeoutException.php';
require_once __DIR__ . '/Buffer.php';
require_once __DIR__ . '/Socket.php';
require_once __DIR__ . '/SourceRcon.php';
require_once __DIR__ . '/GoldSourceRcon.php';
require_once __DIR__ . '/SourceQuery.php';

@ -17,9 +17,8 @@
}, },
"autoload": "autoload":
{ {
"files": "psr-4": {
[ "xPaw\\SourceQuery\\": "SourceQuery/"
"SourceQuery/SourceQuery.class.php" }
]
} }
} }

Loading…
Cancel
Save