Skip to content

Commit

Permalink
feat(Vendor): remove juststeveking/uri-builder, add dependency on Uri…
Browse files Browse the repository at this point in the history
…Inteface
  • Loading branch information
h4kuna authored and pionl committed Mar 11, 2024
1 parent 87e405b commit 9f14a20
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"require": {
"php": ">=8.1",
"guzzlehttp/psr7": "^2.5",
"juststeveking/uri-builder": "^2.0",
"php-http/discovery": "^1.14",
"psr/http-client": "^1.0.1",
"psr/http-message": "^1.0.1 || ^2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace WrkFlow\ApiSdkBuilder;

use Closure;
use JustSteveKing\UriBuilder\Uri;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
use WrkFlow\ApiSdkBuilder\Contracts\ApiFactoryContract;
use WrkFlow\ApiSdkBuilder\Environments\AbstractEnvironment;
use WrkFlow\ApiSdkBuilder\Exceptions\BadRequestException;
Expand Down Expand Up @@ -50,7 +50,7 @@ final public function factory(): ApiFactoryContract
return $this->factory;
}

final public function uri(): Uri
final public function uri(): UriInterface
{
return $this->environment->uri();
}
Expand Down
26 changes: 13 additions & 13 deletions src/Endpoints/AbstractEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace WrkFlow\ApiSdkBuilder\Endpoints;

use Closure;
use JustSteveKing\UriBuilder\Uri;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
use Throwable;
use WrkFlow\ApiSdkBuilder\Contracts\ApiFactoryContract;
use WrkFlow\ApiSdkBuilder\Entities\EndpointDIEntity;
Expand Down Expand Up @@ -85,14 +85,14 @@ final protected function shouldIgnoreLoggersOnException(): ?Closure
*/
abstract protected function basePath(): string;

final protected function uri(string $appendPath = ''): Uri
final protected function uri(string $appendPath = ''): UriInterface
{
$uri = $this->di->api()
->uri();
$basePath = $this->appendSlashIfNeeded($this->basePath());
$appendPath = $this->appendSlashIfNeeded($appendPath);

return $uri->addPath($uri->path() . $basePath . $appendPath);
return $uri->withPath($uri->getPath() . $basePath . $appendPath);
}


Expand All @@ -106,13 +106,13 @@ final protected function uri(string $appendPath = ''): Uri
*/
final protected function sendGet(
string $responseClass,
Uri $uri,
UriInterface $uri,
array $headers = [],
?int $expectedResponseStatusCode = null,
): AbstractResponse {
$request = $this->factory()
->request()
->createRequest('GET', $uri->toString());
->createRequest('GET', (string) $uri);

return $this
->di
Expand Down Expand Up @@ -141,14 +141,14 @@ final protected function sendGet(
*/
final protected function sendPost(
string $responseClass,
Uri $uri,
UriInterface $uri,
OptionsInterface|StreamInterface|string $body = null,
array $headers = [],
?int $expectedResponseStatusCode = null,
): AbstractResponse {
$request = $this->factory()
->request()
->createRequest('POST', $uri->toString());
->createRequest('POST', (string) $uri);

return $this->di->sendRequestAction()
->execute(
Expand Down Expand Up @@ -176,15 +176,15 @@ final protected function sendPost(
*/
final protected function sendPut(
string $responseClass,
Uri $uri,
UriInterface $uri,
OptionsInterface|StreamInterface|string $body = null,
array $headers = [],
?int $expectedResponseStatusCode = null,
Closure $shouldIgnoreLoggersOnError = null,
): AbstractResponse {
$request = $this->factory()
->request()
->createRequest('PUT', $uri->toString());
->createRequest('PUT', (string) $uri);

return $this
->di
Expand Down Expand Up @@ -214,14 +214,14 @@ final protected function sendPut(
*/
final protected function sendDelete(
string $responseClass,
Uri $uri,
UriInterface $uri,
OptionsInterface|StreamInterface|string $body = null,
array $headers = [],
?int $expectedResponseStatusCode = null,
): AbstractResponse {
$request = $this->factory()
->request()
->createRequest('DELETE', $uri->toString());
->createRequest('DELETE', (string) $uri);

return $this
->di
Expand Down Expand Up @@ -254,7 +254,7 @@ final protected function sendDelete(
final protected function sendFake(
ResponseInterface $response,
string $responseClass,
Uri $uri,
UriInterface $uri,
OptionsInterface|StreamInterface|string $body = null,
array $headers = [],
?int $expectedResponseStatusCode = null,
Expand All @@ -269,7 +269,7 @@ final protected function sendFake(
request: $this
->factory()
->request()
->createRequest('FAKE', $uri->toString()),
->createRequest('FAKE', (string) $uri),
responseClass: $responseClass,
body: $body,
headers: $headers,
Expand Down
4 changes: 2 additions & 2 deletions src/Environments/AbstractEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace WrkFlow\ApiSdkBuilder\Environments;

use JustSteveKing\UriBuilder\Uri;
use Psr\Http\Message\UriInterface;
use WrkFlow\ApiSdkBuilder\Interfaces\HeadersInterface;

abstract class AbstractEnvironment implements HeadersInterface
Expand All @@ -17,7 +17,7 @@ public function __construct(
) {
}

abstract public function uri(): Uri;
abstract public function uri(): UriInterface;

public function headers(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Interfaces/ApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace WrkFlow\ApiSdkBuilder\Interfaces;

use Closure;
use JustSteveKing\UriBuilder\Uri;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
use Throwable;
use WrkFlow\ApiSdkBuilder\Contracts\ApiFactoryContract;
use WrkFlow\ApiSdkBuilder\Environments\AbstractEnvironment;
Expand All @@ -27,7 +27,7 @@ public function environment(): AbstractEnvironment;

public function factory(): ApiFactoryContract;

public function uri(): Uri;
public function uri(): UriInterface;

public function createFailedResponseException(int $statusCode, ResponseInterface $response): ResponseException;
}
7 changes: 4 additions & 3 deletions src/Testing/ApiMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
namespace WrkFlow\ApiSdkBuilder\Testing;

use Closure;
use JustSteveKing\UriBuilder\Uri;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
use WrkFlow\ApiSdkBuilder\Contracts\ApiFactoryContract;
use WrkFlow\ApiSdkBuilder\Environments\AbstractEnvironment;
use WrkFlow\ApiSdkBuilder\Exceptions\ResponseException;
Expand All @@ -31,9 +32,9 @@ public function factory(): ApiFactoryContract
return new ApiFactoryMock();
}

public function uri(): Uri
public function uri(): UriInterface
{
return Uri::fromString('https://test.localhost');
return new Uri('https://test.localhost');
}

public function createFailedResponseException(int $statusCode, ResponseInterface $response): ResponseException
Expand Down
4 changes: 2 additions & 2 deletions src/Testing/Environments/TestingEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace WrkFlow\ApiSdkBuilder\Testing\Environments;

use JustSteveKing\UriBuilder\Uri;
use GuzzleHttp\Psr7\Uri;
use WrkFlow\ApiSdkBuilder\Environments\AbstractEnvironment;

class TestingEnvironment extends AbstractEnvironment
{
public function uri(): Uri
{
return Uri::fromString('https://localhost/test');
return new Uri('https://localhost/test');
}
}

0 comments on commit 9f14a20

Please sign in to comment.