From d6b7284ff014ceac8dbac28c8a46aad5da2a3ffe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 09:47:40 +0000 Subject: [PATCH 1/3] chore(internal): php cs fixer should not be memory limited --- .php-cs-fixer.dist.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index e01ea3b..d46a37f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -4,6 +4,8 @@ use PhpCsFixer\Finder; use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; +ini_set('memory_limit', -1); + return (new Config) ->setParallelConfig(ParallelConfigFactory::detect()) ->setFinder(Finder::create()->in([__DIR__.'/src', __DIR__.'/tests'])) From 74f3ced21bafe42f2be6ced3dcaedb5768eddf9f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 09:52:02 +0000 Subject: [PATCH 2/3] feat: use `$_ENV` aware getenv helper --- src/Client.php | 6 ++++-- src/Core/Util.php | 17 +++++++++++++++++ tests/Services/AccountTest.php | 3 ++- tests/Services/Actions/ExecuteTest.php | 3 ++- tests/Services/ActionsTest.php | 3 ++- tests/Services/AuthTest.php | 3 ++- tests/Services/AuthorsTest.php | 3 ++- tests/Services/ContentTest.php | 3 ++- tests/Services/Queue/ItemsTest.php | 3 ++- tests/Services/QueueTest.php | 3 ++- tests/Services/Wordlist/WordsTest.php | 3 ++- tests/Services/WordlistTest.php | 3 ++- 12 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/Client.php b/src/Client.php index 2930653..61e013b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -67,9 +67,11 @@ public function __construct( ?string $baseUrl = null, RequestOptions|array|null $requestOptions = null, ) { - $this->secretKey = (string) ($secretKey ?? getenv('MODAPI_SECRET_KEY')); + $this->secretKey = (string) ($secretKey ?? Util::getenv( + 'MODAPI_SECRET_KEY' + )); - $baseUrl ??= getenv( + $baseUrl ??= Util::getenv( 'MODERATION_API_BASE_URL' ) ?: 'https://api.moderationapi.com/v1'; diff --git a/src/Core/Util.php b/src/Core/Util.php index dd5899a..aff012f 100644 --- a/src/Core/Util.php +++ b/src/Core/Util.php @@ -25,6 +25,23 @@ final class Util public const JSONL_CONTENT_TYPE = '/^application\/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)/'; + public static function getenv(string $key): ?string + { + if (array_key_exists($key, array: $_ENV)) { + if (!is_string($value = $_ENV[$key])) { + throw new \InvalidArgumentException; + } + + return $value; + } + + if (is_string($value = getenv($key))) { + return $value; + } + + return null; + } + /** * @return array */ diff --git a/tests/Services/AccountTest.php b/tests/Services/AccountTest.php index 687514f..d222cd5 100644 --- a/tests/Services/AccountTest.php +++ b/tests/Services/AccountTest.php @@ -4,6 +4,7 @@ use ModerationAPI\Account\AccountListResponse; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -21,7 +22,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/Actions/ExecuteTest.php b/tests/Services/Actions/ExecuteTest.php index 70ac665..d4edbaa 100644 --- a/tests/Services/Actions/ExecuteTest.php +++ b/tests/Services/Actions/ExecuteTest.php @@ -5,6 +5,7 @@ use ModerationAPI\Actions\Execute\ExecuteExecuteByIDResponse; use ModerationAPI\Actions\Execute\ExecuteExecuteResponse; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -22,7 +23,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/ActionsTest.php b/tests/Services/ActionsTest.php index f0e99ea..4762618 100644 --- a/tests/Services/ActionsTest.php +++ b/tests/Services/ActionsTest.php @@ -7,6 +7,7 @@ use ModerationAPI\Actions\ActionNewResponse; use ModerationAPI\Actions\ActionUpdateResponse; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -24,7 +25,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/AuthTest.php b/tests/Services/AuthTest.php index f5cc7e9..ab849f7 100644 --- a/tests/Services/AuthTest.php +++ b/tests/Services/AuthTest.php @@ -5,6 +5,7 @@ use ModerationAPI\Auth\AuthGetResponse; use ModerationAPI\Auth\AuthNewResponse; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -22,7 +23,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/AuthorsTest.php b/tests/Services/AuthorsTest.php index d31c051..bcaa3a5 100644 --- a/tests/Services/AuthorsTest.php +++ b/tests/Services/AuthorsTest.php @@ -8,6 +8,7 @@ use ModerationAPI\Authors\AuthorNewResponse; use ModerationAPI\Authors\AuthorUpdateResponse; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -25,7 +26,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/ContentTest.php b/tests/Services/ContentTest.php index 20506e6..5c1d6c1 100644 --- a/tests/Services/ContentTest.php +++ b/tests/Services/ContentTest.php @@ -4,6 +4,7 @@ use ModerationAPI\Client; use ModerationAPI\Content\ContentSubmitResponse; +use ModerationAPI\Core\Util; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -21,7 +22,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/Queue/ItemsTest.php b/tests/Services/Queue/ItemsTest.php index 4ed2c8b..1270e1a 100644 --- a/tests/Services/Queue/ItemsTest.php +++ b/tests/Services/Queue/ItemsTest.php @@ -3,6 +3,7 @@ namespace Tests\Services\Queue; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use ModerationAPI\Queue\Items\ItemListResponse; use ModerationAPI\Queue\Items\ItemResolveResponse; use ModerationAPI\Queue\Items\ItemUnresolveResponse; @@ -23,7 +24,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/QueueTest.php b/tests/Services/QueueTest.php index 85eb27f..46c6bcd 100644 --- a/tests/Services/QueueTest.php +++ b/tests/Services/QueueTest.php @@ -3,6 +3,7 @@ namespace Tests\Services; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use ModerationAPI\Queue\QueueGetResponse; use ModerationAPI\Queue\QueueGetStatsResponse; use PHPUnit\Framework\Attributes\CoversNothing; @@ -22,7 +23,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/Wordlist/WordsTest.php b/tests/Services/Wordlist/WordsTest.php index e5d3f00..6d478f6 100644 --- a/tests/Services/Wordlist/WordsTest.php +++ b/tests/Services/Wordlist/WordsTest.php @@ -3,6 +3,7 @@ namespace Tests\Services\Wordlist; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use ModerationAPI\Wordlist\Words\WordAddResponse; use ModerationAPI\Wordlist\Words\WordRemoveResponse; use PHPUnit\Framework\Attributes\CoversNothing; @@ -22,7 +23,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; diff --git a/tests/Services/WordlistTest.php b/tests/Services/WordlistTest.php index 9eeffa7..9da9f2a 100644 --- a/tests/Services/WordlistTest.php +++ b/tests/Services/WordlistTest.php @@ -3,6 +3,7 @@ namespace Tests\Services; use ModerationAPI\Client; +use ModerationAPI\Core\Util; use ModerationAPI\Wordlist\WordlistGetEmbeddingStatusResponse; use ModerationAPI\Wordlist\WordlistGetResponse; use ModerationAPI\Wordlist\WordlistUpdateResponse; @@ -23,7 +24,7 @@ protected function setUp(): void { parent::setUp(); - $testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; + $testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010'; $client = new Client(secretKey: 'My Secret Key', baseUrl: $testUrl); $this->client = $client; From 47a61010c8c4e382ce81469f4bb5b8b4b8b4467a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 09:52:43 +0000 Subject: [PATCH 3/3] release: 0.5.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 13 +++++++++++++ README.md | 2 +- src/Version.php | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index da59f99..2aca35a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.4.0" + ".": "0.5.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c5dd414..b3429ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.5.0 (2026-02-03) + +Full Changelog: [v0.4.0...v0.5.0](https://github.com/moderation-api/sdk-php/compare/v0.4.0...v0.5.0) + +### Features + +* use `$_ENV` aware getenv helper ([74f3ced](https://github.com/moderation-api/sdk-php/commit/74f3ced21bafe42f2be6ced3dcaedb5768eddf9f)) + + +### Chores + +* **internal:** php cs fixer should not be memory limited ([d6b7284](https://github.com/moderation-api/sdk-php/commit/d6b7284ff014ceac8dbac28c8a46aad5da2a3ffe)) + ## 0.4.0 (2026-01-31) Full Changelog: [v0.3.0...v0.4.0](https://github.com/moderation-api/sdk-php/compare/v0.3.0...v0.4.0) diff --git a/README.md b/README.md index 6554aa7..3ce9174 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The REST API documentation can be found on [docs.moderationapi.com](https://docs ``` -composer require "moderation-api/sdk-php 0.4.0" +composer require "moderation-api/sdk-php 0.5.0" ``` diff --git a/src/Version.php b/src/Version.php index 5b5aacf..589ebba 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace ModerationAPI; // x-release-please-start-version -const VERSION = '0.4.0'; +const VERSION = '0.5.0'; // x-release-please-end