steffospieler / codestats
A simple api wrapper for Code::Stats with some helper functions.
v1.0.0
2025-07-14 19:21 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.9
Requires (Dev)
- pestphp/pest: ^2.36
- vimeo/psalm: ^5.26
This package is auto-updated.
Last update: 2025-08-19 13:12:33 UTC
README
A simple API wrapper for the Code::Stats API with helpful utility functions.
Setup
To use the CodeStats wrapper, you'll need to create a client with a descriptive user agent:
use SteffoSpieler\CodeStats\Client;
$client = new Client("Example for PHP Code::Stats API Wrapper");
Examples
Get user information:
use SteffoSpieler\CodeStats\Client;
$client = new Client("Example for PHP Code::Stats API Wrapper");
$user = $client->getUser("username");
Add pulse:
use SteffoSpieler\CodeStats\Client;
use SteffoSpieler\CodeStats\Classes\PulseLanguage;
$client = new Client("Example for PHP Code::Stats API Wrapper");
$user = $client->addPulse(
"SFMyNTY.OEotWWdnPT0jI01qaz0.X0wVEZquh8Ogau1iTtBihYqqL71FD8N6p5ChQiIpaxQ",
[
new PulseLanguage("PHP", 45),
new PulseLanguage("Markdown", 30),
],
new DateTime()
);
Get level (and more) out of XP:
use SteffoSpieler\CodeStats\XPCalculator;
XPCalculator::getLevel(123456); // 8
XPCalculator::getLevelProgress(123456); // 77
XPCalculator::getNextLevelXp(8); // 129600
Contributing
Contributions are always welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.