Skip to content

Commit

Permalink
add: code documentation and code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
yzPeedro committed Jun 25, 2022
1 parent 67ecb88 commit efd4670
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 18 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"guzzlehttp/guzzle": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"symfony/var-dumper": "^6.1"
},
"license": "MIT"
}
198 changes: 184 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Auth/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Authentication
private string $api_key;

/**
* Create an Authentication class instance.
*
* @param string $api_key
*/
public function __construct(string $api_key = '')
Expand All @@ -22,6 +24,8 @@ public function __construct(string $api_key = '')
}

/**
* Set yor api key in instance, you can get at R6Stats Discord (https://discord.gg/2Hz8wrKk3z).
*
* @param string $api_key
*/
public function setApiKey(string $api_key): void
Expand All @@ -30,6 +34,8 @@ public function setApiKey(string $api_key): void
}

/**
* Get yor api key in instance, if you don't have an api key, you can get at R6Stats Discord (https://discord.gg/2Hz8wrKk3z).
*
* @return string
*/
public function getApiKey(): string
Expand Down
7 changes: 6 additions & 1 deletion src/Stats/Contracts/GameInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

namespace RainbowStats\RainbowStats\Stats\Contracts;

use stdClass;

interface GameInterface
{
public function leaderboard(): array|string|\stdClass;
/**
* @return array|string|stdClass
*/
public function leaderboard(): array|string|stdClass;
}
16 changes: 15 additions & 1 deletion src/Stats/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,29 @@

class Game implements GameInterface
{
/**
* @var StatsApi
*/
private StatsApi $api;

/**
* Create a Game class instance.
*
* @param Authentication $authentication
* @param array $data
*/
public function __construct(Authentication $authentication, array $data)
{
$this->api = new StatsApi($authentication, $data);
}

/**
* Get the game leaderboard. Returns an array with a maximum of 100 objects with information for each player.
*
* @return array|string|stdClass
*/
public function leaderboard(): array|string|stdClass
{
return $this->api->leaderboard('game');
return $this->api->leaderboard();
}
}
Loading

0 comments on commit efd4670

Please sign in to comment.