Skip to content

Commit 526c43e

Browse files
refactor(exception): rename Exception to ApiException to avoid PHP built-in conflict
1 parent d612ef0 commit 526c43e

7 files changed

Lines changed: 16 additions & 16 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ make dev-push
3636

3737
## Architecture Overview
3838

39-
This is a minimal, agnostic PHP SDK for OpenAPI services with only essential HTTP primitives. The architecture follows a clean, simple design inspired by the Rust implementation found in `reference/openapi-rust-sdk/`.
39+
This is a minimal, agnostic PHP SDK for Openapi services with only essential HTTP primitives. The architecture follows a clean, simple design inspired by the Rust implementation found in `reference/openapi-rust-sdk/`.
4040

4141
### Core Components
4242

@@ -60,7 +60,7 @@ This is a minimal, agnostic PHP SDK for OpenAPI services with only essential HTT
6060

6161
### Key Design Principles
6262

63-
1. **Agnostic**: No API-specific classes - works with any OpenAPI service
63+
1. **Agnostic**: No API-specific classes - works with any Openapi service
6464
2. **Minimal**: Only core HTTP primitives, minimal dependencies (PHP 8.0+, cURL, JSON)
6565
3. **Clean Interface**: Simple method signatures following REST conventions
6666
4. **Environment Flexibility**: Built-in test/production environment switching

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Before using the Openapi PHP Client, you will need an account at [Openapi](https
2525

2626
## Features
2727

28-
- **Agnostic Design**: No API-specific classes, works with any OpenAPI service
28+
- **Agnostic Design**: No API-specific classes, works with any Openapi service
2929
- **Minimal Dependencies**: Only requires PHP 8.0+ and cURL
3030
- **OAuth Support**: Built-in OAuth client for token management
3131
- **HTTP Primitives**: GET, POST, PUT, DELETE, PATCH methods

docs/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ To report bugs or request features, please **open an issue** on GitHub including
5252
- Steps to reproduce (if applicable).
5353
- Relevant logs or error output.
5454

55-
Thank you for helping improve the OpenAPI PHP SDK!
55+
Thank you for helping improve the Openapi PHP SDK!

examples/complete_workflow.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use Openapi\OauthClient;
66
use Openapi\Client;
7-
use Openapi\Exception;
7+
use Openapi\ApiException;
88

99
try {
10-
echo "=== OpenAPI PHP SDK Complete Workflow Example ===" . PHP_EOL . PHP_EOL;
10+
echo "=== Openapi PHP SDK Complete Workflow Example ===" . PHP_EOL . PHP_EOL;
1111

1212
// Step 1: Create OAuth client
1313
echo "Step 1: Creating OAuth client..." . PHP_EOL;
@@ -25,7 +25,7 @@
2525
$tokenData = json_decode($tokenResult, true);
2626

2727
if (!isset($tokenData['token'])) {
28-
throw new Exception('Failed to generate token: ' . $tokenResult);
28+
throw new ApiException('Failed to generate token: ' . $tokenResult);
2929
}
3030

3131
$token = $tokenData['token'];
@@ -62,7 +62,7 @@
6262

6363
echo "=== Workflow completed successfully! ===" . PHP_EOL;
6464

65-
} catch (Exception $e) {
65+
} catch (ApiException $e) {
6666
echo "✗ Error: " . $e->getMessage() . PHP_EOL;
6767

6868
if ($e->getHttpCode()) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Openapi;
44

5-
class Exception extends \Exception
5+
class ApiException extends \Exception
66
{
77
private mixed $serverResponse = null;
88
private mixed $headers = null;

src/OauthClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ private function request(string $method, string $url, ?array $body = null): stri
8282

8383
// TODO: Provide more graceful error message with connection context (timeout, DNS, SSL, etc.)
8484
if ($response === false) {
85-
throw new Exception("cURL Error: " . $error);
85+
throw new ApiException("cURL Error: " . $error);
8686
}
8787

8888
// TODO: Parse response body and provide structured error details with auth-specific hints
8989
if ($httpCode >= 400) {
90-
throw new Exception("HTTP Error {$httpCode}: " . $response);
90+
throw new ApiException("HTTP Error {$httpCode}: " . $response);
9191
}
9292

9393
return $response;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?php
22

3-
use Openapi\Exception;
3+
use Openapi\ApiException;
44
use PHPUnit\Framework\TestCase;
55

6-
final class ExceptionTest extends TestCase
6+
final class ApiExceptionTest extends TestCase
77
{
8-
public function testExceptionCreation(): void
8+
public function testApiExceptionCreation(): void
99
{
1010
$message = 'Test exception message';
1111
$code = 400;
1212

13-
$exception = new Exception($message, $code);
13+
$exception = new ApiException($message, $code);
1414

1515
$this->assertEquals($message, $exception->getMessage());
1616
$this->assertEquals($code, $exception->getCode());
1717
}
1818

1919
public function testSetServerResponse(): void
2020
{
21-
$exception = new Exception('Test message');
21+
$exception = new ApiException('Test message');
2222

2323
$response = ['error' => 'Server error'];
2424
$headers = 'Content-Type: application/json';

0 commit comments

Comments
 (0)