diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index fca6aa4..0658e20 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -8,6 +8,24 @@ on: 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 diff --git a/composer.json b/composer.json index 084241e..802e032 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ }, "require-dev": { "phpunit/phpunit": "^9.6", - "friendsofphp/php-cs-fixer": "^3.58" + "friendsofphp/php-cs-fixer": "^3.58", + "phpstan/phpstan": "^1.11" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 5b0945f..7f3f4c5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e960c827904bd4589fdbba562be69885", + "content-hash": "742b713e90945bc6ddfaa70138c1c1fc", "packages": [ { "name": "guzzlehttp/guzzle", @@ -1399,6 +1399,64 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.11.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "9100a76ce8015b9aa7125b9171ae3a76887b6c82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9100a76ce8015b9aa7125b9171ae3a76887b6c82", + "reference": "9100a76ce8015b9aa7125b9171ae3a76887b6c82", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-06-06T12:19:22+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.31", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..d8a2bce --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 6 + paths: + - src + - tests + diff --git a/src/Client.php b/src/Client.php index 42b044e..9bab78c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -19,11 +19,6 @@ class Client */ private GuzzleClient $httpClient; - /** - * @var string API access token - */ - private string $accessToken; - /** * @var string Base URI for the Oura API */ @@ -49,7 +44,6 @@ public function __construct(string $accessToken, string $apiVersion = 'v2') 'Accept' => 'application/json', ], ]); - $this->accessToken = $accessToken; $this->apiVersion = $apiVersion; } @@ -58,7 +52,7 @@ public function __construct(string $accessToken, string $apiVersion = 'v2') * * @param string $method HTTP method (GET, POST, etc.) * @param string $endpoint API endpoint - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object * @throws RuntimeException if the request fails */ @@ -80,7 +74,7 @@ private function makeRequest(string $method, string $endpoint, array $params = [ /** * Retrieves heart rate data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getHeartRate(array $params = []): ResponseInterface @@ -91,7 +85,7 @@ public function getHeartRate(array $params = []): ResponseInterface /** * Retrieves personal info data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getPersonalInfo(array $params = []): ResponseInterface @@ -102,7 +96,7 @@ public function getPersonalInfo(array $params = []): ResponseInterface /** * Retrieves tag data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getTag(array $params = []): ResponseInterface @@ -113,7 +107,7 @@ public function getTag(array $params = []): ResponseInterface /** * Retrieves enhanced tag data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getEnhancedTag(array $params = []): ResponseInterface @@ -124,7 +118,7 @@ public function getEnhancedTag(array $params = []): ResponseInterface /** * Retrieves workout data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getWorkout(array $params = []): ResponseInterface @@ -135,7 +129,7 @@ public function getWorkout(array $params = []): ResponseInterface /** * Retrieves session data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getSession(array $params = []): ResponseInterface @@ -146,7 +140,7 @@ public function getSession(array $params = []): ResponseInterface /** * Retrieves daily activity data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailyActivity(array $params = []): ResponseInterface @@ -157,7 +151,7 @@ public function getDailyActivity(array $params = []): ResponseInterface /** * Retrieves daily sleep data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailySleep(array $params = []): ResponseInterface @@ -168,7 +162,7 @@ public function getDailySleep(array $params = []): ResponseInterface /** * Retrieves daily SPO2 data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailySpo2(array $params = []): ResponseInterface @@ -179,7 +173,7 @@ public function getDailySpo2(array $params = []): ResponseInterface /** * Retrieves daily readiness data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailyReadiness(array $params = []): ResponseInterface @@ -190,7 +184,7 @@ public function getDailyReadiness(array $params = []): ResponseInterface /** * Retrieves sleep data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getSleep(array $params = []): ResponseInterface @@ -201,7 +195,7 @@ public function getSleep(array $params = []): ResponseInterface /** * Retrieves sleep time data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getSleepTime(array $params = []): ResponseInterface @@ -212,7 +206,7 @@ public function getSleepTime(array $params = []): ResponseInterface /** * Retrieves rest mode period data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getRestModePeriod(array $params = []): ResponseInterface @@ -223,7 +217,7 @@ public function getRestModePeriod(array $params = []): ResponseInterface /** * Retrieves ring configuration data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getRingConfiguration(array $params = []): ResponseInterface @@ -234,7 +228,7 @@ public function getRingConfiguration(array $params = []): ResponseInterface /** * Retrieves daily stress data * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailyStress(array $params = []): ResponseInterface @@ -246,7 +240,7 @@ public function getDailyStress(array $params = []): ResponseInterface * Retrieves tag data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getTagById(string $documentId, array $params = []): ResponseInterface @@ -258,7 +252,7 @@ public function getTagById(string $documentId, array $params = []): ResponseInte * Retrieves enhanced tag data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getEnhancedTagById(string $documentId, array $params = []): ResponseInterface @@ -270,7 +264,7 @@ public function getEnhancedTagById(string $documentId, array $params = []): Resp * Retrieves workout data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getWorkoutById(string $documentId, array $params = []): ResponseInterface @@ -282,7 +276,7 @@ public function getWorkoutById(string $documentId, array $params = []): Response * Retrieves session data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getSessionById(string $documentId, array $params = []): ResponseInterface @@ -294,7 +288,7 @@ public function getSessionById(string $documentId, array $params = []): Response * Retrieves daily activity data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailyActivityById(string $documentId, array $params = []): ResponseInterface @@ -306,7 +300,7 @@ public function getDailyActivityById(string $documentId, array $params = []): Re * Retrieves daily sleep data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailySleepById(string $documentId, array $params = []): ResponseInterface @@ -318,7 +312,7 @@ public function getDailySleepById(string $documentId, array $params = []): Respo * Retrieves daily SPO2 data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailySpo2ById(string $documentId, array $params = []): ResponseInterface @@ -330,7 +324,7 @@ public function getDailySpo2ById(string $documentId, array $params = []): Respon * Retrieves daily readiness data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailyReadinessById(string $documentId, array $params = []): ResponseInterface @@ -342,7 +336,7 @@ public function getDailyReadinessById(string $documentId, array $params = []): R * Retrieves sleep data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getSleepById(string $documentId, array $params = []): ResponseInterface @@ -354,7 +348,7 @@ public function getSleepById(string $documentId, array $params = []): ResponseIn * Retrieves sleep time data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getSleepTimeById(string $documentId, array $params = []): ResponseInterface @@ -366,7 +360,7 @@ public function getSleepTimeById(string $documentId, array $params = []): Respon * Retrieves rest mode period data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getRestModePeriodById(string $documentId, array $params = []): ResponseInterface @@ -378,7 +372,7 @@ public function getRestModePeriodById(string $documentId, array $params = []): R * Retrieves ring configuration data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getRingConfigurationById(string $documentId, array $params = []): ResponseInterface @@ -390,7 +384,7 @@ public function getRingConfigurationById(string $documentId, array $params = []) * Retrieves daily stress data by document ID * * @param string $documentId Document ID - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface PSR-7 Response object */ public function getDailyStressById(string $documentId, array $params = []): ResponseInterface @@ -402,7 +396,7 @@ public function getDailyStressById(string $documentId, array $params = []): Resp * Retrieves all pages of data for a given endpoint * * @param string $endpoint API endpoint - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllPages(string $endpoint, array $params = []): array @@ -428,7 +422,7 @@ public function getAllPages(string $endpoint, array $params = []): array /** * Retrieves all heart rate data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllHeartRate(array $params = []): array @@ -439,7 +433,7 @@ public function getAllHeartRate(array $params = []): array /** * Retrieves all workout data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllWorkout(array $params = []): array @@ -450,7 +444,7 @@ public function getAllWorkout(array $params = []): array /** * Retrieves all tag data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllTag(array $params = []): array @@ -461,7 +455,7 @@ public function getAllTag(array $params = []): array /** * Retrieves all enhanced tag data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllEnhancedTag(array $params = []): array @@ -472,7 +466,7 @@ public function getAllEnhancedTag(array $params = []): array /** * Retrieves all session data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllSession(array $params = []): array @@ -483,7 +477,7 @@ public function getAllSession(array $params = []): array /** * Retrieves all daily activity data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllDailyActivity(array $params = []): array @@ -494,7 +488,7 @@ public function getAllDailyActivity(array $params = []): array /** * Retrieves all daily sleep data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllDailySleep(array $params = []): array @@ -505,7 +499,7 @@ public function getAllDailySleep(array $params = []): array /** * Retrieves all daily SPO2 data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllDailySpo2(array $params = []): array @@ -516,7 +510,7 @@ public function getAllDailySpo2(array $params = []): array /** * Retrieves all daily readiness data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllDailyReadiness(array $params = []): array @@ -527,7 +521,7 @@ public function getAllDailyReadiness(array $params = []): array /** * Retrieves all sleep data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllSleep(array $params = []): array @@ -538,7 +532,7 @@ public function getAllSleep(array $params = []): array /** * Retrieves all sleep time data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllSleepTime(array $params = []): array @@ -549,7 +543,7 @@ public function getAllSleepTime(array $params = []): array /** * Retrieves all rest mode period data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllRestModePeriod(array $params = []): array @@ -560,7 +554,7 @@ public function getAllRestModePeriod(array $params = []): array /** * Retrieves all ring configuration data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllRingConfiguration(array $params = []): array @@ -571,7 +565,7 @@ public function getAllRingConfiguration(array $params = []): array /** * Retrieves all daily stress data, handling pagination * - * @param array $params Query parameters + * @param array $params Query parameters * @return ResponseInterface[] Array of PSR-7 Response objects */ public function getAllDailyStress(array $params = []): array