Skip to content

Commit 3d71315

Browse files
authored
Merge pull request #3 from teamreflex/2.x
2.0
2 parents a99d7df + bed6f70 commit 3d71315

32 files changed

+5050
-400
lines changed

.github/workflows/test.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
php: [ 7.4 ]
12+
dependency-version: [prefer-lowest, prefer-stable]
13+
14+
name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v1
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v1
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: mbstring, sqlite, pdo_sqlite, iconv
25+
coverage: none
26+
27+
- name: Cache dependencies
28+
uses: actions/cache@v1
29+
with:
30+
path: ~/.composer/cache/files
31+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
32+
33+
- name: Install dependencies
34+
run: |
35+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
36+
37+
- name: Execute tests
38+
run: vendor/bin/phpunit

.gitignore

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
ChallongePHP.sublime-project
2-
ChallongePHP.sublime-workspace
3-
/vendor/
4-
5-
composer.lock
6-
7-
index.php
1+
/vendor
2+
/.idea
3+
/.phpunit.cache
4+
.phpunit.result.cache

README.md

+51-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,57 @@
11
# ChallongePHP
2-
Package for interfacing with the [Challonge] API.
32

4-
You can find basic documentation in the wiki: https://github.com/teamreflex/ChallongePHP/wiki
3+
![Test](https://github.com/teamreflex/ChallongePHP/workflows/Test/badge.svg?branch=master)
4+
[![Latest Version](https://img.shields.io/packagist/v/team-reflex/challonge-php.svg)](https://packagist.org/packages/team-reflex/challonge-php)
5+
[![Downloads](https://img.shields.io/packagist/dt/team-reflex/challonge-php.svg)](https://packagist.org/packages/team-reflex/challonge-php)
56

6-
- [team-reflex.com](https://team-reflex.com)
7+
PSR-18 compliant package for interfacing with the [Challonge] API.
8+
9+
## Installation
10+
Requires PHP 7.4 as it takes advantage of its type support.
11+
12+
Install via composer:
13+
14+
```bash
15+
composer require team-reflex/challonge-php
16+
```
17+
18+
## Usage
19+
As the package is PSR-18 compliant, it does not come with an HTTP client by default.
20+
21+
You can use a client such as Guzzle, and pass an instance of it when instantiating:
22+
23+
```bash
24+
$http = new GuzzleHttp\Client();
25+
$challonge = new Challonge($http, 'api_key_here', true);
26+
```
27+
28+
By default, the package maps the keys of any input, as Challonge requires its input to be in a format such as:
29+
30+
```bash
31+
$tournament = $challonge->createTournament([
32+
'tournament[name]' => 'test'
33+
]);
34+
```
35+
36+
Which means you are able to use the package without prefixing your keys:
37+
38+
```bash
39+
$tournament = $challonge->createTournament([
40+
'name' => 'test'
41+
]);
42+
```
43+
44+
You can change the third argument to `false` to disable this mapping if you would prefer to do it yourself.
45+
46+
Now you're ready to make requests:
47+
48+
```bash
49+
$tournament = $challonge->fetchTournament('challongephptest');
50+
```
51+
52+
As the package is fully type-hinted, everything should be self documenting, however there is documentation in the wiki.
53+
54+
## Contact
755
- [@Reflexgg](http://twitter.com/Reflexgg)
856
- [@Kairuxo](http://twitter.com/Kairuxo)
957

composer.json

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
22
"name": "team-reflex/challonge-php",
3-
"description": "Unofficial API to interface with the bracket generator Challonge.",
3+
"description": "PSR-18 compatible library to interface with the bracket generator Challonge.",
44
"require": {
5-
"guzzlehttp/guzzle": "^6.0"
5+
"ext-json": "*",
6+
"php": "^7.4",
7+
"psr/http-client": "^1.0",
8+
"illuminate/collections": "~8.0 | ~7.0 | ~6.0",
9+
"spatie/data-transfer-object": "^2.5"
10+
},
11+
"require-dev": {
12+
"phpunit/phpunit": "^9.4",
13+
"guzzlehttp/guzzle": "^7.2"
614
},
715
"license": "MIT",
816
"authors": [
@@ -15,5 +23,13 @@
1523
"psr-4": {
1624
"Reflex\\Challonge\\": "src/Challonge"
1725
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"Tests\\": "tests"
30+
}
31+
},
32+
"scripts": {
33+
"test": "vendor/bin/phpunit"
1834
}
1935
}

0 commit comments

Comments
 (0)