Skip to content

Commit d198d6e

Browse files
committed
Use a static factory instead of the immutable setter.
1 parent 60d70c0 commit d198d6e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/BigBlueButton.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,25 @@ public function __construct(?string $baseUrl = null, ?string $secret = null, ?ar
144144
}
145145

146146
/**
147-
* Immutable setter. Sets a http client and factories.
147+
* Creates an instance with http client and factories.
148148
*
149149
* It is recommended for the http client to have a timeout of e.g. 10
150150
* seconds, to avoid hanging requests. The timeout from ->setTimeout() will
151151
* have no effect on an instance created in this way.
152152
*/
153-
public function withHttpClient(
153+
public static function createWithHttpClient(
154154
ClientInterface $httpClient,
155155
RequestFactoryInterface $requestFactory,
156156
StreamFactoryInterface $streamFactory,
157+
?string $baseUrl = null,
158+
?string $secret = null,
157159
): static {
158-
$clone = clone $this;
159-
$clone->httpClient = $httpClient;
160-
$clone->requestFactory = $requestFactory;
161-
$clone->streamFactory = $streamFactory;
160+
$instance = new static($baseUrl, $secret);
161+
$instance->httpClient = $httpClient;
162+
$instance->requestFactory = $requestFactory;
163+
$instance->streamFactory = $streamFactory;
162164

163-
return $clone;
165+
return $instance;
164166
}
165167

166168
/**

0 commit comments

Comments
 (0)