Skip to content

Commit aa09892

Browse files
committed
Clone a client instance
1 parent d4f8541 commit aa09892

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Client.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ public function __destruct() {
187187
$this->disconnect();
188188
}
189189

190+
/**
191+
* Clone the current Client instance
192+
*
193+
* @return Client
194+
*/
195+
public function clone(): Client {
196+
$client = new self();
197+
$client->events = $this->events;
198+
$client->timeout = $this->timeout;
199+
$client->active_folder = $this->active_folder;
200+
$client->default_account_config = $this->default_account_config;
201+
$config = $this->getAccountConfig();
202+
foreach($config as $key => $value) {
203+
$client->setAccountConfig($key, $config, $this->default_account_config);
204+
}
205+
$client->default_message_mask = $this->default_message_mask;
206+
$client->default_attachment_mask = $this->default_message_mask;
207+
return $client;
208+
}
209+
190210
/**
191211
* Set the Client configuration
192212
* @param array $config

0 commit comments

Comments
 (0)