Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
init
  • Loading branch information
slvler committed Jun 30, 2023
0 parents commit a27e7e7
Show file tree
Hide file tree
Showing 17 changed files with 612 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/tests export-ignore
/.editorconfig export-ignore
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
build
composer.lock
docs
vendor
coverage
.phpunit.result.cache
.php-cs-fixer.cache
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.xml
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode

4 changes: 4 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
preset: laravel

disabled:
- single_class_element_per_statement
Empty file added CONTRIBUTING.md
Empty file.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2023 slvler <slvler@proton.me>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
233 changes: 233 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
# slvler - covalenthq Service

[![tests](https://github.com/slvler/covalenthq-service/actions/workflows/tests.yml/badge.svg)](https://github.com/slvler/covalenthq-servicee/actions/workflows/tests.yml)
[![Latest Stable Version](http://poser.pugx.org/slvler/covalent/v)](https://packagist.org/packages/slvler/covalent)
[![Latest Unstable Version](http://poser.pugx.org/slvler/covalent/v/unstable)](https://packagist.org/packages/slvler/covalent)
[![License](http://poser.pugx.org/slvler/covalent/license)](https://packagist.org/packages/slvler/covalent)


This package provides a convenient wrapper to the [Balldontlie API](https://www.balldontlie.io/home.html#introduction) for Laravel applications.

## Requirements

- PHP 8.0+
- Laravel 9.x

## Installation

To install this package tou can use composer:

```bash
composer require slvler/covalent
```

## Usage

#### Find player
``` php
Balldontlie::players(237);
```
it returns an json with player:
```
{
"data":[
{
"id":237,
"first_name":"LeBron",
"last_name":"James",
"position":"F",
"height_feet": 6,
"height_inches": 8,
"weight_pounds": 250,
"team":{
"id":14,
"abbreviation":"LAL",
"city":"Los Angeles",
"conference":"West",
"division":"Pacific",
"full_name":"Los Angeles Lakers",
"name":"Lakers"
}
}
...
],
"meta": {
"total_pages": 50,
"current_page": 1,
"next_page": 2,
"per_page": 25,
"total_count": 9999
}
}
```



#### Find team
``` php
Balldontlie::teams(14);
```
it returns an json with team:
```
{
"data": [
{
"id":14,
"abbreviation":"LAL",
"city":"Los Angeles",
"conference":"West",
"division":"Pacific",
"full_name":"Los Angeles Lakers",
"name":"Lakers"
},
...
],
"meta": {
"total_pages": 1,
"current_page": 1,
"next_page": null,
"per_page": 30,
"total_count": 30
}
}
```



#### Find games
``` php
Balldontlie::games(1);
```
it returns an json with games:
```
{
"data": [
{
"id":1,
"date":"2018-10-16T00:00:00.000Z",
"home_team_score":105,
"visitor_team_score":87,
"season":2018,
"period": 4,
"status": "Final",
"time": " ",
"postseason": false,
"home_team":{
"id":2,
"abbreviation":"BOS",
"city":"Boston",
"conference":"East",
"division":"Atlantic",
"full_name":"Boston Celtics",
"name":"Celtics"
},
"visitor_team":{
"id":23,
"abbreviation":"PHI",
"city":"Philadelphia",
"conference":"East",
"division":"Atlantic",
"full_name":"Philadelphia 76ers",
"name":"76ers"
},
},
...
],
"meta": {
"total_pages": 1877,
"current_page": 1,
"next_page": 2,
"per_page": 25,
"total_count": 46911
}
}
```




#### Find stats
``` php
Balldontlie::stats();
```
it returns an json with stats:
```
{
"data": [
{
"id":29,
"ast":2,
"blk":2,
"dreb":8,
"fg3_pct":0.25,
"fg3a":4,
"fg3m":1,
"fg_pct":0.429,
"fga":21,
"fgm":9,
"ft_pct":0.8,
"fta":5,
"ftm":4,
"game":{
"id":1,
"date":"2018-10-16T00:00:00.000Z",
"home_team_id":2,
"home_team_score":105,
"season":2018,
"visitor_team_id":23,
"visitor_team_score":87
},
"min":"36:49",
"oreb":2,
"pf":3,
"player":{
"id":145,
"first_name":"Joel",
"last_name":"Embiid",
"position":"F-C",
"team_id":23
},
"pts":23,
"reb":10,
"stl":1,
"team":{
"id":23,
"abbreviation":"PHI",
"city":"Philadelphia",
"conference":"East",
"division":"Atlantic",
"full_name":"Philadelphia 76ers",
"name":"76ers"
},
"turnover":5
},
...
],
"meta": {
"total_pages": 2042,
"current_page": 1,
"next_page": 2,
"per_page": 25,
"total_count": 51045
}
}
```


## Testing

```bash
composer test
```

## Credits

- [slvler](https://github.com/slvler)

## License

The MIT License (MIT). Please see [License File](https://github.com/slvler/balldontlie-service/blob/main/LICENSE.md) for more information.

## Contributing
You're very welcome to contribute.
Please see [CONTRIBUTING](https://github.com/slvler/balldontlie-service/blob/main/CONTRIBUTING.md) for details.
54 changes: 54 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "slvler/balldontlie-laravel",
"description": "balldontlie API wrapper for Laravel",
"keywords": [
"balldontlie",
"laravel",
"php"
],
"homepage": "https://github.com/slvler/balldontlie-service",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "slvler",
"email": "slvler@proton.me"
}
],
"require": {
"php": "^8.0.2",
"guzzlehttp/guzzle": "^7.2",
"illuminate/support": "^9.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.6",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.5.8"
},
"autoload": {
"psr-4": {
"Slvler\\BalldontlieLaravel\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Slvler\\BalldontlieLaravel\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit tests",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
"extra": {
"laravel": {
"providers": [
"Slvler\\BalldontlieLaravel\\BalldontlieServiceProvider"
],
"aliases": {
"Balldontlie": "Slvler\\BalldontlieLaravel\\Facades\\Balldontlie"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
5 changes: 5 additions & 0 deletions config/balldontlie.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'base_uri' => 'https://www.balldontlie.io/api/v1/'
];
20 changes: 20 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</phpunit>
20 changes: 20 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</phpunit>
Loading

0 comments on commit a27e7e7

Please sign in to comment.