Skip to content

Commit 5501e2c

Browse files
committed
Pass a UrlBuilder instance to the static factory, instead of base url and secret.
1 parent bf8ac29 commit 5501e2c

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

src/BigBlueButton.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,18 @@ public static function createWithHttpClient(
158158
ClientInterface $httpClient,
159159
RequestFactoryInterface $requestFactory,
160160
StreamFactoryInterface $streamFactory,
161-
string $baseUrl,
162-
#[\SensitiveParameter]
163-
string $secret,
161+
UrlBuilder $urlBuilder,
164162
): static {
165163
// Extending classes need to override this method, if they change the
166164
// constructor signature.
167165
// @phpstan-ignore new.static
168-
$instance = new static($baseUrl, $secret);
166+
$instance = new static(
167+
// The current version of the constructor does not support injecting
168+
// A UrlBuilder instance. As a stop-gap, extract the relevant values
169+
// so that a new instance will be created in the constructor.
170+
$urlBuilder->getBaseUrl(),
171+
$urlBuilder->getSecret(),
172+
);
169173
$instance->httpClient = $httpClient;
170174
$instance->requestFactory = $requestFactory;
171175
$instance->streamFactory = $streamFactory;

src/Util/UrlBuilder.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ public function setSecret(
6868
return $this;
6969
}
7070

71+
/**
72+
* Gets the secret.
73+
*
74+
* This method only exists to support a deprecated property in the
75+
* BigBlueButton class.
76+
*
77+
* @internal
78+
*/
79+
public function getSecret(): string
80+
{
81+
return $this->secret;
82+
}
83+
7184
public function setBaseUrl(string $baseUrl): self
7285
{
7386
// add tailing dir-separator if missing
@@ -80,6 +93,19 @@ public function setBaseUrl(string $baseUrl): self
8093
return $this;
8194
}
8295

96+
/**
97+
* Gets the base url.
98+
*
99+
* This method only exists to support a deprecated property in the
100+
* BigBlueButton class.
101+
*
102+
* @internal
103+
*/
104+
public function getBaseUrl(): string
105+
{
106+
return $this->baseUrl;
107+
}
108+
83109
public function setHashingAlgorithm(HashingAlgorithm $hashingAlgorithm): self
84110
{
85111
$this->hashingAlgorithm = $hashingAlgorithm;

tests/BigBlueButtonGuzzleTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace BigBlueButton;
2222

23+
use BigBlueButton\Enum\HashingAlgorithm;
24+
use BigBlueButton\Util\UrlBuilder;
2325
use GuzzleHttp\Client;
2426
use GuzzleHttp\Psr7\HttpFactory;
2527

@@ -46,8 +48,11 @@ public function setUp(): void
4648
$client,
4749
$factory,
4850
$factory,
49-
getenv('BBB_SERVER_BASE_URL') ?: $this->fail(),
50-
getenv('BBB_SECRET') ?: getenv('BBB_SECURITY_SALT') ?: $this->fail(),
51+
new UrlBuilder(
52+
getenv('BBB_SECRET') ?: getenv('BBB_SECURITY_SALT') ?: $this->fail(),
53+
getenv('BBB_SERVER_BASE_URL') ?: $this->fail(),
54+
HashingAlgorithm::SHA_256,
55+
),
5156
);
5257
}
5358
}

tests/Util/FixturesGuzzleTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
namespace BigBlueButton\Util;
2222

2323
use BigBlueButton\BigBlueButton;
24+
use BigBlueButton\Enum\HashingAlgorithm;
2425
use GuzzleHttp\Client;
2526
use GuzzleHttp\Psr7\HttpFactory;
2627

@@ -40,8 +41,11 @@ public function setUp(): void
4041
$client,
4142
$factory,
4243
$factory,
43-
getenv('BBB_SERVER_BASE_URL') ?: $this->fail(),
44-
getenv('BBB_SECRET') ?: getenv('BBB_SECURITY_SALT') ?: $this->fail(),
44+
new UrlBuilder(
45+
getenv('BBB_SECRET') ?: getenv('BBB_SECURITY_SALT') ?: $this->fail(),
46+
getenv('BBB_SERVER_BASE_URL') ?: $this->fail(),
47+
HashingAlgorithm::SHA_256,
48+
),
4549
);
4650

4751
parent::setUp();

0 commit comments

Comments
 (0)