Skip to content

Large refactoring (ideas for v3?) #150

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

Closed
wants to merge 20 commits into from
Closed
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
8 changes: 0 additions & 8 deletions .editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
- uses: actions/checkout@v1
- name: Install dependencies
run: composer install --no-interaction --no-progress
- name: Run cs-fixer
run: php${{ matrix.php }} vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php
- name: Run tests
run: php${{ matrix.php }} vendor/bin/phpunit --configuration Tests/phpunit.xml --verbose --fail-on-warning
- name: Run phpstan
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
vendor/
composer.lock
.php-cs-fixer.cache
.idea/
Tests/.phpunit.result.cache
54 changes: 54 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR1' => true,
'@PSR12' => true,
'@PSR12:risky' => true,
'@PSR2' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP54Migration' => true,
'@PHP56Migration:risky' => true,
'@PHP70Migration' => true,
'@PHP70Migration:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,
'@PHP80Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit30Migration:risky' => true,
'@PHPUnit32Migration:risky' => true,
'@PHPUnit35Migration:risky' => true,
'@PHPUnit43Migration:risky' => true,
'@PHPUnit48Migration:risky' => true,
'@PHPUnit50Migration:risky' => true,
'@PHPUnit52Migration:risky' => true,
'@PHPUnit54Migration:risky' => true,
'@PHPUnit55Migration:risky' => true,
'@PHPUnit56Migration:risky' => true,
'@PHPUnit57Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'concat_space' => false,
'native_constant_invocation' => false,
'native_function_invocation' => false,
'php_unit_fqcn_annotation' => false,
'php_unit_test_case_static_method_calls' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in('Examples')
->in('SourceQuery')
->in('Tests')
)
;
55 changes: 23 additions & 32 deletions Examples/Example.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
<?php
require __DIR__ . '/../SourceQuery/bootstrap.php';

use xPaw\SourceQuery\SourceQuery;

// For the sake of this example
header( 'Content-Type: text/plain' );
header( 'X-Content-Type-Options: nosniff' );

// Edit this ->
define( 'SQ_SERVER_ADDR', 'localhost' );
define( 'SQ_SERVER_PORT', 27015 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );
// Edit this <-

$Query = new SourceQuery( );

try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );

print_r( $Query->GetInfo( ) );
print_r( $Query->GetPlayers( ) );
print_r( $Query->GetRules( ) );
}
catch( Exception $e )
{
echo $e->getMessage( );
}
finally
{
$Query->Disconnect( );
}
declare(strict_types=1);

require_once __DIR__ . '/../vendor/autoload.php';

use xPaw\SourceQuery\SourceQueryFactory;

// For the sake of this example.
header('Content-Type: text/plain');
header('X-Content-Type-Options: nosniff');

$query = SourceQueryFactory::createSourceQuery();

try {
$query->connect('localhost', 27015, 1);

print_r($query->getInfo());
print_r($query->getPlayers());
print_r($query->getRules());
} catch (Exception $exception) {
echo $exception->getMessage();
} finally {
$query->disconnect();
}
57 changes: 24 additions & 33 deletions Examples/RconExample.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
<?php
require __DIR__ . '/../SourceQuery/bootstrap.php';

use xPaw\SourceQuery\SourceQuery;

// For the sake of this example
header( 'Content-Type: text/plain' );
header( 'X-Content-Type-Options: nosniff' );

// Edit this ->
define( 'SQ_SERVER_ADDR', 'localhost' );
define( 'SQ_SERVER_PORT', 27015 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );
// Edit this <-

$Query = new SourceQuery( );

try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );

$Query->SetRconPassword( 'my_awesome_password' );

var_dump( $Query->Rcon( 'say hello' ) );
}
catch( Exception $e )
{
echo $e->getMessage( );
}
finally
{
$Query->Disconnect( );
}

declare(strict_types=1);

require_once __DIR__ . '/../vendor/autoload.php';

use xPaw\SourceQuery\SourceQueryFactory;

// For the sake of this example.
header('Content-Type: text/plain');
header('X-Content-Type-Options: nosniff');

$query = SourceQueryFactory::createSourceQuery();

try {
$query->connect('localhost', 27015, 1);

$query->setRconPassword('my_awesome_password');

var_dump($query->rcon('say hello'));
} catch (Exception $exception) {
echo $exception->getMessage();
} finally {
$query->disconnect();
}
Loading