1
0
mirror of https://github.com/xPaw/PHP-Source-Query.git synced 2026-06-11 02:13:14 +02:00

Move the response array logic into classes.

This commit is contained in:
Anthony Birkett
2021-05-31 18:52:56 +01:00
parent 96a875c881
commit 5d54dc8929
14 changed files with 383 additions and 207 deletions
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
/**
* @author Pavel Djundik
*
* @see https://xpaw.me
* @see https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/
namespace xPaw\SourceQuery\QueryResponse;
use xPaw\SourceQuery\Buffer;
use xPaw\SourceQuery\Exception\InvalidPacketException;
class RulesQueryResponse
{
/**
* @throws InvalidPacketException
*/
public static function fromBuffer(Buffer $buffer): array
{
$rules = [];
$count = $buffer->getShort();
while ($count-- > 0 && !$buffer->isEmpty()) {
$rule = $buffer->getString();
$value = $buffer->getString();
if (!empty($rule)) {
$rules[$rule] = $value;
}
}
return $rules;
}
}