Skip to content

Commit 9e76676

Browse files
committed
Use a static factory instead of the immutable setter.
1 parent fe302ee commit 9e76676

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/BigBlueButton.php

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

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

161-
return $clone;
163+
return $instance;
162164
}
163165

164166
/**

0 commit comments

Comments
 (0)