Skip to content

Commit d612ef0

Browse files
refactor(naming): remove Openapi prefix from all class and file names
1 parent 55b677d commit d612ef0

18 files changed

Lines changed: 61 additions & 74 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"Openapi\\": "src"
5959
},
6060
"files": [
61-
"src/OpenapiBootstrap.php"
61+
"src/Bootstrap.php"
6262
]
6363
},
6464
"autoload-dev": {

examples/api_calls.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
use Openapi\OpenapiClient;
5+
use Openapi\Client;
66

77
try {
88
$token = '<your_access_token>';
9-
$client = new OpenapiClient($token);
9+
$client = new Client($token);
1010

1111
// GET request with parameters
1212
$params = [

examples/complete_workflow.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
require_once __DIR__ . '/../vendor/autoload.php';
44

55
use Openapi\OauthClient;
6-
use Openapi\OpenapiClient;
7-
use Openapi\OpenapiException;
6+
use Openapi\Client;
7+
use Openapi\Exception;
88

99
try {
1010
echo "=== OpenAPI PHP SDK Complete Workflow Example ===" . PHP_EOL . PHP_EOL;
@@ -25,15 +25,15 @@
2525
$tokenData = json_decode($tokenResult, true);
2626

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

3131
$token = $tokenData['token'];
3232
echo "✓ Token generated: " . substr($token, 0, 20) . "..." . PHP_EOL . PHP_EOL;
3333

3434
// Step 3: Create API client
3535
echo "Step 3: Creating API client..." . PHP_EOL;
36-
$apiClient = new OpenapiClient($token);
36+
$apiClient = new Client($token);
3737
echo "✓ API client created" . PHP_EOL . PHP_EOL;
3838

3939
// Step 4: Make API calls
@@ -62,7 +62,7 @@
6262

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

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

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

33
declare(strict_types=1);
44

5-
use Openapi\Environment\DotEnv\OpenapiDotEnv;
5+
use Openapi\Environment\DotEnv;
66
use Composer\Autoload\ClassLoader;
77

88
if (!function_exists('shouldLoad')) {
@@ -27,7 +27,7 @@ function findProjectRoot(): ?string
2727
return null;
2828
}
2929

30-
$reflection = new ReflectionClass(ClassLoader::class);
30+
$reflection = new \ReflectionClass(ClassLoader::class);
3131
$vendorDir = dirname($reflection->getFileName(), 2);
3232
$projectRoot = dirname($vendorDir);
3333

@@ -38,6 +38,6 @@ function findProjectRoot(): ?string
3838
if (shouldLoad()) {
3939
$projectRoot = findProjectRoot();
4040
if ($projectRoot !== null) {
41-
(new OpenapiDotEnv($projectRoot . DIRECTORY_SEPARATOR . '.env'))->load();
41+
(new DotEnv($projectRoot . DIRECTORY_SEPARATOR . '.env'))->load();
4242
}
4343
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Openapi\Cache;
44

5-
class OpenapiArrayCache implements OpenapiCacheInterface
5+
class ArrayCache implements CacheInterface
66
{
77
private array $cache = [];
88
private array $expiry = [];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Openapi\Cache;
44

5-
interface OpenapiCacheInterface
5+
interface CacheInterface
66
{
77
public function get(string $key): mixed;
88

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
namespace Openapi;
44

5-
use Openapi\Interfaces\OpenapiHttpTransportInterface;
6-
use Openapi\Transports\OpenapiCurlTransport;
5+
use Openapi\Interfaces\HttpTransportInterface;
6+
use Openapi\Transports\CurlTransport;
77
use Psr\Http\Client\ClientInterface as PsrClientInterface;
88

9-
class OpenapiClient
9+
class Client
1010
{
1111
private string $token;
12-
private OpenapiHttpTransportInterface|PsrClientInterface $transport;
12+
private HttpTransportInterface|PsrClientInterface $transport;
1313
private ?string $baseUrl = null;
1414

15-
public function __construct(?string $token = null, OpenapiHttpTransportInterface|PsrClientInterface|null $transport = null)
15+
public function __construct(?string $token = null, HttpTransportInterface|PsrClientInterface|null $transport = null)
1616
{
1717
$this->token = $token ?? getenv('OPEN_API_TOKEN');
1818
if (getenv('OPENAPI_BASE_URL')) {
1919
$this->baseUrl = getenv('OPENAPI_BASE_URL');
2020
}
21-
$this->transport = $transport ?? new OpenapiCurlTransport($this->token);
21+
$this->transport = $transport ?? new CurlTransport($this->token);
2222
}
2323

2424
public function request(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Openapi\Environment\DotEnv;
3+
namespace Openapi\Environment;
44

5-
class OpenapiDotEnv
5+
class DotEnv
66
{
77
protected string $path;
88

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Openapi;
44

5-
class OpenapiException extends \Exception
5+
class Exception extends \Exception
66
{
77
private mixed $serverResponse = null;
88
private mixed $headers = null;
99
private mixed $rawResponse = null;
1010
private ?int $httpCode = null;
1111

1212
/**
13-
* TODO: Utilize this method in OpenapiClient and OauthClient to provide structured error context
13+
* TODO: Utilize this method in Client and OauthClient to provide structured error context
1414
*/
1515
public function setServerResponse(mixed $response, mixed $headers = null, mixed $rawResponse = null, ?int $httpCode = null): void
1616
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Openapi\Interfaces;
44

5-
interface OpenapiDotEnvInterface
5+
interface DotEnvInterface
66
{
77
public function load(): void;
88
}

0 commit comments

Comments
 (0)