-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/development'
- Loading branch information
Showing
37 changed files
with
488 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/.github/ export-ignore | ||
/tests/ export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php-cs-fixer.dist.php export-ignore | ||
/phpstan.dist.neon export-ignore | ||
/phpstan-baseline.neon export-ignore | ||
/phpunit.xml.dist export-ignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CI | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- windows-latest | ||
|
||
php-version: | ||
- 8.2 | ||
- 8.3 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install PHP with extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
ini-values: memory_limit=-1, assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On | ||
|
||
- name: Install dependencies with Composer | ||
run: composer install --prefer-dist --no-ansi --no-interaction --no-progress | ||
|
||
- name: Run PHP-CS-Fixer in Linter Mode | ||
run: composer run-script php-cs-fixer -- --dry-run --show-progress=dots --using-cache=no --verbose | ||
|
||
- name: Run PHPStan | ||
run: composer run-script phpstan | ||
|
||
- name: Run test-suites | ||
run: composer run-script test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "**" | ||
|
||
jobs: | ||
create-release: | ||
name: Create Release | ||
|
||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Determine tag | ||
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
|
||
- name: Create release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ env.RELEASE_TAG }} | ||
name: v${{ env.RELEASE_TAG }} | ||
generateReleaseNotes: true | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/.phpunit.cache/ | ||
/composer.lock | ||
/phpunit.xml | ||
/.php-cs-fixer.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
* (c) Ahmed Ghanem <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
$header = <<<EOF | ||
This file is part of the TempNumberClient package. | ||
(c) Ahmed Ghanem <[email protected]> | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/src') | ||
->in(__DIR__ . '/tests') | ||
->ignoreVCSIgnored(true); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRules([ | ||
'@PSR12' => true, | ||
'@PSR12:risky' => true | ||
]) | ||
->setUsingCache(true) | ||
->setRiskyAllowed(true) | ||
->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^Method ahmedghanem00\\\\TempNumberClient\\\\Exception\\\\API\\\\APIException\\:\\:newFromErrorName\\(\\) should return static\\(ahmedghanem00\\\\TempNumberClient\\\\Exception\\\\API\\\\APIException\\) but returns ahmedghanem00\\\\TempNumberClient\\\\Exception\\\\API\\\\APIException\\.$#" | ||
count: 1 | ||
path: src/Exception/API/APIException.php | ||
|
||
- | ||
message: "#^Unreachable statement \\- code above always terminates\\.$#" | ||
count: 2 | ||
path: tests/Unit/ClientTest.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
includes: | ||
- phpstan-baseline.neon | ||
|
||
parameters: | ||
level: 5 | ||
|
||
paths: | ||
- src/ | ||
- tests/ | ||
|
||
reportUnmatchedIgnoredErrors: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ This file is part of the TempNumberClient package. | ||
~ | ||
~ (c) Ahmed Ghanem <[email protected]> | ||
~ | ||
~ For the full copyright and license information, please view the LICENSE | ||
~ file that was distributed with this source code. | ||
--> | ||
|
||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
cacheResultFile=".phpunit.cache/test-results" | ||
cacheDirectory=".phpunit.cache" | ||
executionOrder="depends,defects" | ||
forceCoversAnnotation="true" | ||
beStrictAboutCoversAnnotation="true" | ||
requireCoverageMetadata="true" | ||
beStrictAboutCoverageMetadata="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
convertDeprecationsToExceptions="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
verbose="true"> | ||
failOnWarning="true"> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory>tests/unit</directory> | ||
<testsuite name="Unit"> | ||
<directory>tests/Unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<php> | ||
<env name="API_KEY" value="" force="true" /> | ||
<env name="BACKEND_SERVER" value="Mock" force="true" /> | ||
<env name="API_KEY" value="" force="true"/> | ||
<env name="BACKEND_SERVER" value="Mock" force="true"/> | ||
</php> | ||
|
||
<coverage cacheDirectory=".phpunit.cache/code-coverage" | ||
processUncoveredFiles="true"> | ||
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
<directory>src</directory> | ||
</include> | ||
</coverage> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
<?php declare(strict_types=1); | ||
<?php | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
* (c) Ahmed Ghanem <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
|
@@ -57,8 +67,7 @@ public function __construct( | |
string $apiKey, | ||
?HttpClientInterface $httpClient = null, | ||
TempNumberServer $backendServer = TempNumberServer::Production | ||
) | ||
{ | ||
) { | ||
$this->setHttpClient($httpClient ?? HttpClient::create()); | ||
$this->setApiKey($apiKey); | ||
$this->setBackendServer($backendServer); | ||
|
@@ -79,7 +88,7 @@ public function setApiKey(#[\SensitiveParameter] string $apiKey): void | |
} | ||
|
||
/** | ||
* @param array<string, string|array> $options | ||
* @param array<string, string|array|int> $options | ||
* @return void | ||
*/ | ||
public function applyHttpClientOptions(array $options): void | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
<?php declare(strict_types=1); | ||
<?php | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
* (c) Ahmed Ghanem <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
<?php declare(strict_types=1); | ||
<?php | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
* (c) Ahmed Ghanem <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
<?php declare(strict_types=1); | ||
<?php | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
* (c) Ahmed Ghanem <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
<?php declare(strict_types=1); | ||
<?php | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
* (c) Ahmed Ghanem <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
/* | ||
* This file is part of the TempNumberClient package. | ||
* | ||
|
@@ -15,4 +25,14 @@ enum TempNumberServer: string | |
case Production = 'https://tn-api.com/api/v1/'; | ||
|
||
case Mock = 'https://mock.temp-number.org/v1/'; | ||
|
||
public static function fromName(string $name): self | ||
{ | ||
foreach (self::cases() as $status) { | ||
if ($name === $status->name) { | ||
return $status; | ||
} | ||
} | ||
throw new \ValueError("$name is not a valid backing value for enum " . self::class); | ||
} | ||
} |
Oops, something went wrong.