Skip to content

Commit 99b1f80

Browse files
committed
Merge branch 'refs/heads/development'
2 parents 1a1b43a + 8ef6c0c commit 99b1f80

37 files changed

+488
-116
lines changed

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.github/ export-ignore
2+
/tests/ export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/.php-cs-fixer.dist.php export-ignore
6+
/phpstan.dist.neon export-ignore
7+
/phpstan-baseline.neon export-ignore
8+
/phpunit.xml.dist export-ignore
9+

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
tests:
9+
name: Tests
10+
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
16+
matrix:
17+
os:
18+
- ubuntu-latest
19+
- windows-latest
20+
21+
php-version:
22+
- 8.2
23+
- 8.3
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install PHP with extensions
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-version }}
33+
ini-values: memory_limit=-1, assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
34+
35+
- name: Install dependencies with Composer
36+
run: composer install --prefer-dist --no-ansi --no-interaction --no-progress
37+
38+
- name: Run PHP-CS-Fixer in Linter Mode
39+
run: composer run-script php-cs-fixer -- --dry-run --show-progress=dots --using-cache=no --verbose
40+
41+
- name: Run PHPStan
42+
run: composer run-script phpstan
43+
44+
- name: Run test-suites
45+
run: composer run-script test

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "**"
7+
8+
jobs:
9+
create-release:
10+
name: Create Release
11+
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Determine tag
22+
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
23+
24+
- name: Create release
25+
uses: ncipollo/release-action@v1
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
tag: ${{ env.RELEASE_TAG }}
29+
name: v${{ env.RELEASE_TAG }}
30+
generateReleaseNotes: true
31+

.github/workflows/testing.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/.phpunit.cache/
44
/composer.lock
55
/phpunit.xml
6+
/.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/*
3+
* This file is part of the TempNumberClient package.
4+
*
5+
* (c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
$header = <<<EOF
14+
This file is part of the TempNumberClient package.
15+
16+
(c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
17+
18+
For the full copyright and license information, please view the LICENSE
19+
file that was distributed with this source code.
20+
EOF;
21+
22+
$finder = PhpCsFixer\Finder::create()
23+
->in(__DIR__ . '/src')
24+
->in(__DIR__ . '/tests')
25+
->ignoreVCSIgnored(true);
26+
27+
return (new PhpCsFixer\Config())
28+
->setRules([
29+
'@PSR12' => true,
30+
'@PSR12:risky' => true
31+
])
32+
->setUsingCache(true)
33+
->setRiskyAllowed(true)
34+
->setFinder($finder);

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,21 @@
3030
},
3131

3232
"require": {
33-
"php": ">=8.2",
34-
"symfony/http-client": "6.*",
35-
"doctrine/collections": "2.*"
33+
"php": "^8.2",
34+
"symfony/http-client": "^6.0 || ^7.0",
35+
"doctrine/collections": "^2.0"
3636
},
3737

3838
"require-dev": {
3939
"phpunit/phpunit": "dev-main",
40-
"phpstan/phpstan": "1.10.x-dev"
40+
"phpstan/phpstan": "1.10.x-dev",
41+
"friendsofphp/php-cs-fixer": "^3.54"
4142
},
4243

4344
"scripts": {
44-
"test": "@php vendor/bin/phpunit",
45-
"phpstan": "@php vendor/bin/phpstan analyse src tests"
45+
"test": "vendor/bin/phpunit",
46+
"phpstan": "vendor/bin/phpstan analyse",
47+
"php-cs-fixer": "vendor/bin/php-cs-fixer fix"
4648
},
4749

4850
"minimum-stability": "stable"

phpstan-baseline.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Method ahmedghanem00\\\\TempNumberClient\\\\Exception\\\\API\\\\APIException\\:\\:newFromErrorName\\(\\) should return static\\(ahmedghanem00\\\\TempNumberClient\\\\Exception\\\\API\\\\APIException\\) but returns ahmedghanem00\\\\TempNumberClient\\\\Exception\\\\API\\\\APIException\\.$#"
5+
count: 1
6+
path: src/Exception/API/APIException.php
7+
8+
-
9+
message: "#^Unreachable statement \\- code above always terminates\\.$#"
10+
count: 2
11+
path: tests/Unit/ClientTest.php

phpstan.dist.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 5
6+
7+
paths:
8+
- src/
9+
- tests/
10+
11+
reportUnmatchedIgnoredErrors: true

phpunit.xml.dist

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ This file is part of the TempNumberClient package.
4+
~
5+
~ (c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
6+
~
7+
~ For the full copyright and license information, please view the LICENSE
8+
~ file that was distributed with this source code.
9+
-->
10+
211
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
12+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
413
bootstrap="vendor/autoload.php"
5-
cacheResultFile=".phpunit.cache/test-results"
14+
cacheDirectory=".phpunit.cache"
615
executionOrder="depends,defects"
7-
forceCoversAnnotation="true"
8-
beStrictAboutCoversAnnotation="true"
16+
requireCoverageMetadata="true"
17+
beStrictAboutCoverageMetadata="true"
918
beStrictAboutOutputDuringTests="true"
10-
beStrictAboutTodoAnnotatedTests="true"
11-
convertDeprecationsToExceptions="true"
1219
failOnRisky="true"
13-
failOnWarning="true"
14-
verbose="true">
20+
failOnWarning="true">
1521
<testsuites>
16-
<testsuite name="unit">
17-
<directory>tests/unit</directory>
22+
<testsuite name="Unit">
23+
<directory>tests/Unit</directory>
1824
</testsuite>
1925
</testsuites>
2026

2127
<php>
22-
<env name="API_KEY" value="" force="true" />
23-
<env name="BACKEND_SERVER" value="Mock" force="true" />
28+
<env name="API_KEY" value="" force="true"/>
29+
<env name="BACKEND_SERVER" value="Mock" force="true"/>
2430
</php>
2531

26-
<coverage cacheDirectory=".phpunit.cache/code-coverage"
27-
processUncoveredFiles="true">
32+
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
2833
<include>
29-
<directory suffix=".php">src</directory>
34+
<directory>src</directory>
3035
</include>
31-
</coverage>
36+
</source>
3237
</phpunit>

src/Client.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
/*
3+
* This file is part of the TempNumberClient package.
4+
*
5+
* (c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
declare(strict_types=1);
212
/*
313
* This file is part of the TempNumberClient package.
414
*
@@ -57,8 +67,7 @@ public function __construct(
5767
string $apiKey,
5868
?HttpClientInterface $httpClient = null,
5969
TempNumberServer $backendServer = TempNumberServer::Production
60-
)
61-
{
70+
) {
6271
$this->setHttpClient($httpClient ?? HttpClient::create());
6372
$this->setApiKey($apiKey);
6473
$this->setBackendServer($backendServer);
@@ -79,7 +88,7 @@ public function setApiKey(#[\SensitiveParameter] string $apiKey): void
7988
}
8089

8190
/**
82-
* @param array<string, string|array> $options
91+
* @param array<string, string|array|int> $options
8392
* @return void
8493
*/
8594
public function applyHttpClientOptions(array $options): void

src/Enum/ActivationStatus.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
/*
3+
* This file is part of the TempNumberClient package.
4+
*
5+
* (c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
declare(strict_types=1);
212
/*
313
* This file is part of the TempNumberClient package.
414
*

src/Enum/Country.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
/*
3+
* This file is part of the TempNumberClient package.
4+
*
5+
* (c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
declare(strict_types=1);
212
/*
313
* This file is part of the TempNumberClient package.
414
*

src/Enum/Service.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
/*
3+
* This file is part of the TempNumberClient package.
4+
*
5+
* (c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
declare(strict_types=1);
212
/*
313
* This file is part of the TempNumberClient package.
414
*

src/Enum/TempNumberServer.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
/*
3+
* This file is part of the TempNumberClient package.
4+
*
5+
* (c) Ahmed Ghanem <ahmedghanem7361@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
declare(strict_types=1);
212
/*
313
* This file is part of the TempNumberClient package.
414
*
@@ -15,4 +25,14 @@ enum TempNumberServer: string
1525
case Production = 'https://tn-api.com/api/v1/';
1626

1727
case Mock = 'https://mock.temp-number.org/v1/';
28+
29+
public static function fromName(string $name): self
30+
{
31+
foreach (self::cases() as $status) {
32+
if ($name === $status->name) {
33+
return $status;
34+
}
35+
}
36+
throw new \ValueError("$name is not a valid backing value for enum " . self::class);
37+
}
1838
}

0 commit comments

Comments
 (0)