Skip to content

Commit

Permalink
Merge pull request #1 from tai-sho/features/improve-env
Browse files Browse the repository at this point in the history
Improvement of the environment
  • Loading branch information
tai-sho authored Jun 9, 2024
2 parents 7ef5367 + 81f28b5 commit bc4c459
Show file tree
Hide file tree
Showing 11 changed files with 4,011 additions and 852 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/code_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Code quality check

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
phpstan:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon

phpunit:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit

phpmd:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPMD
run: vendor/bin/phpmd src github phpmd.xml

php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHP CS Fixer
run: ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor
.idea
.phpunit.result.cache
.php-cs-fixer.cache
88 changes: 88 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => ['return']
],
'braces' => [
'position_after_functions_and_oop_constructs' => 'next'
],
'cast_spaces' => ['space' => 'single'],
'class_definition' => ['multi_line_extends_each_single_line' => true],
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'function_typehint_space' => true,
'include' => true,
'lowercase_cast' => true,
'native_function_casing' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => [
'tokens' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use'
]
],
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'echo'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'phpdoc_indent' => true,
'phpdoc_tag_type' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => false,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none'
],
'semicolon_after_instruction' => true,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'general_phpdoc_tag_rename' => true,
'phpdoc_inline_tag_normalizer' => true
])
->setFinder($finder);

106 changes: 106 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Contributing to Oura API PHP Client

First off, thanks for taking the time to contribute! 🎉

The following is a set of guidelines for contributing to this project. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

## How Can I Contribute?

### Reporting Bugs

This section guides you through submitting a bug report for the Oura API PHP Client. Following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports.

Before creating a bug report, please check if an issue has already been reported.

1. **Check the [issues](https://github.com/your-username/oura-api-php/issues) for similar problems.**
2. **If you find a related issue, add a comment with any additional details.**
3. **If your issue is unique, open a new issue:**
- Use a clear and descriptive title for the issue to identify the problem.
- Provide as much relevant information as possible to help others understand the problem and how to reproduce it.

### Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for the Oura API PHP Client, including completely new features and minor improvements to existing functionality.

1. **Check the [issues](https://github.com/your-username/oura-api-php/issues) for similar suggestions.**
2. **If you find a related suggestion, add a comment with your thoughts.**
3. **If your suggestion is new, open a new issue:**
- Use a clear and descriptive title for the issue to identify the suggestion.
- Provide a detailed description of the suggested enhancement and explain why it would be beneficial.

### Submitting a Pull Request

1. Fork the repository.
2. Clone your fork to your local machine:
```sh
git clone https://github.com/your-username/oura-api-php.git
cd oura-api-php
```
3. Create a new branch for your changes:
```
git checkout -b feature/your-feature-name
```
4. Make your changes in your branch.
5. Commit your changes:
```sh
git commit -m "Description of your changes"
```
6. Push to your fork:
```sh
git push origin feature/your-feature-name
```
7. Open a pull request from your forked repository to the main repository.

### Pull Request Guidelines
- Ensure any install or build dependencies are removed before the end of the layer when doing a build.
- Update the README.md and any other relevant documentation with details of changes to the interface.
- Ensure the test suite passes.
- Make sure your code lints.

## Development
### Using Docker for Development
We provide a Docker setup to ensure a consistent development environment. To use Docker:
1. Build the Docker image:
```sh
docker-compose build
```
2. Run the development environment:
```sh
docker-compose up
```
3. Use the php environment:
```sh
docker-compose exec app bash
```

The Docker setup will automatically install dependencies and run tests, code style checks and static analysis.

### Code Style, Analysis and Testing
Please ensure your code adheres to our coding standards and passes all checks:
1. PHP-CS-Fixer: Ensures code style consistency.
```sh
composer fix
```
2. PHPStan: Performs static analysis to detect potential issues.
```sh
composer analyse
```
3. PHPMD: Checks for code smells and potential bugs.
```sh
composer md
```
4. PHPUnit: Unit testing.
```sh
composer test
```

You can run all tests and checks with a single command:
```sh
composer all-checks
```

## Code of Conduct
This project and everyone participating in it is governed by the Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

## Thank You
Thank you for considering contributing to the Oura API PHP Client! We look forward to building something amazing with you.
88 changes: 46 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# oura-api-php
[![Latest Stable Version](https://poser.pugx.org/tai-sho/oura-api-php/v/stable)](https://packagist.org/packages/tai-sho/oura-api-php)
[![Build Status](https://github.com/tai-sho/oura-api-php/actions/workflows/code_check.yml/badge.svg)](https://github.com/tai-sho/oura-api-php/actions/workflows/code_check.yml)
[![License](https://poser.pugx.org/tai-sho/oura-api-php/license)](https://packagist.org/packages/tai-sho/oura-api-php)
[![Twitter Follow](https://img.shields.io/twitter/follow/tai-sho.svg?style=social&label=Follow)](https://twitter.com/tai-sho)

A PHP client library for the Oura Ring API.

Expand Down Expand Up @@ -67,50 +71,50 @@ foreach ($responses as $response) {
## Available Endpoints
The client supports the following endpoints:

- getHeartRate(array $params = [])
- getPersonalInfo(array $params = [])
- getTag(array $params = [])
- getEnhancedTag(array $params = [])
- getWorkout(array $params = [])
- getSession(array $params = [])
- getDailyActivity(array $params = [])
- getDailySleep(array $params = [])
- getDailySpo2(array $params = [])
- getDailyReadiness(array $params = [])
- getSleep(array $params = [])
- getSleepTime(array $params = [])
- getRestModePeriod(array $params = [])
- getRingConfiguration(array $params = [])
- getDailyStress(array $params = [])
- getTagById(string $documentId, array $params = [])
- getEnhancedTagById(string $documentId, array $params = [])
- getWorkoutById(string $documentId, array $params = [])
- getSessionById(string $documentId, array $params = [])
- getDailyActivityById(string $documentId, array $params = [])
- getDailySleepById(string $documentId, array $params = [])
- getDailySpo2ById(string $documentId, array $params = [])
- getDailyReadinessById(string $documentId, array $params = [])
- getSleepById(string $documentId, array $params = [])
- getSleepTimeById(string $documentId, array $params = [])
- getRestModePeriodById(string $documentId, array $params = [])
- getRingConfigurationById(string $documentId, array $params = [])
- getDailyStressById(string $documentId, array $params = [])
- `getHeartRate(array $params = [])`
- `getPersonalInfo(array $params = [])`
- `getTag(array $params = [])`
- `getEnhancedTag(array $params = [])`
- `getWorkout(array $params = [])`
- `getSession(array $params = [])`
- `getDailyActivity(array $params = [])`
- `getDailySleep(array $params = [])`
- `getDailySpo2(array $params = [])`
- `getDailyReadiness(array $params = [])`
- `getSleep(array $params = [])`
- `getSleepTime(array $params = [])`
- `getRestModePeriod(array $params = [])`
- `getRingConfiguration(array $params = [])`
- `getDailyStress(array $params = [])`
- `getTagById(string $documentId, array $params = [])`
- `getEnhancedTagById(string $documentId, array $params = [])`
- `getWorkoutById(string $documentId, array $params = [])`
- `getSessionById(string $documentId, array $params = [])`
- `getDailyActivityById(string $documentId, array $params = [])`
- `getDailySleepById(string $documentId, array $params = [])`
- `getDailySpo2ById(string $documentId, array $params = [])`
- `getDailyReadinessById(string $documentId, array $params = [])`
- `getSleepById(string $documentId, array $params = [])`
- `getSleepTimeById(string $documentId, array $params = [])`
- `getRestModePeriodById(string $documentId, array $params = [])`
- `getRingConfigurationById(string $documentId, array $params = [])`
- `getDailyStressById(string $documentId, array $params = [])`

## Get All Data Functions (Handling Pagination)
- getAllHeartRateData(array $params = [])
- getAllWorkoutData(array $params = [])
- getAllTagData(array $params = [])
- getAllEnhancedTagData(array $params = [])
- getAllSessionData(array $params = [])
- getAllDailyActivityData(array $params = [])
- getAllDailySleepData(array $params = [])
- getAllDailySpo2Data(array $params = [])
- getAllDailyReadinessData(array $params = [])
- getAllSleepData(array $params = [])
- getAllSleepTimeData(array $params = [])
- getAllRestModePeriodData(array $params = [])
- getAllRingConfigurationData(array $params = [])
- getAllDailyStressData(array $params = [])
- `getAllHeartRateData(array $params = [])`
- `getAllWorkoutData(array $params = [])`
- `getAllTagData(array $params = [])`
- `getAllEnhancedTagData(array $params = [])`
- `getAllSessionData(array $params = [])`
- `getAllDailyActivityData(array $params = [])`
- `getAllDailySleepData(array $params = [])`
- `getAllDailySpo2Data(array $params = [])`
- `getAllDailyReadinessData(array $params = [])`
- `getAllSleepData(array $params = [])`
- `getAllSleepTimeData(array $params = [])`
- `getAllRestModePeriodData(array $params = [])`
- `getAllRingConfigurationData(array $params = [])`
- `getAllDailyStressData(array $params = [])`

# Contributing
Welcome contributions! Please submit a pull request or open an issue to discuss changes.
Expand Down
Loading

0 comments on commit bc4c459

Please sign in to comment.