Skip to content

Commit 774dc86

Browse files
committed
feat: allow for http adapter param
- Base client class now accepts Http Adapter object as param. - Add http adapter interface
1 parent 8c311c0 commit 774dc86

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/recurly/base_client.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ abstract class BaseClient
2323
*
2424
* @param string $api_key The API key to use when making requests
2525
*/
26-
public function __construct(string $api_key, LoggerInterface $logger = null)
26+
public function __construct(string $api_key, LoggerInterface $logger = null, HttpAdapterInterface $http_adapter = null)
2727
{
2828
$this->_api_key = $api_key;
29-
$this->http = new HttpAdapter;
29+
if (is_null($http_adapter)) {
30+
$http_adapter = new HttpAdapter;
31+
}
32+
$this->http = $http_adapter;
3033
if (is_null($logger)) {
3134
$logger = new \Recurly\Logger('Recurly', LogLevel::WARNING);
3235
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Recurly;
4+
5+
/**
6+
* @codeCoverageIgnore
7+
*/
8+
interface HttpAdapterInterface
9+
{
10+
public function execute($method, $url, $body, $headers): array;
11+
}

0 commit comments

Comments
 (0)