Skip to content

Commit

Permalink
ClientManager::make() method added to support undefined accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Oct 9, 2020
1 parent 0c61e09 commit 13e76da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## [UNRELEASED]
### Fixed
- NaN
- `ClientManager::make()` method added to support undefined accounts

### Added
- NaN
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ $cm = new ClientManager($options = []);
$client = $cm->account('account_identifier');

// or create a new instance manually
$client = new Client([
$client = $cm->make([
'host' => 'somehost.com',
'port' => 993,
'encryption' => 'ssl',
Expand Down Expand Up @@ -205,10 +205,12 @@ $folder = $client->getFolder('INBOX.name');
#### oAuth
If you are using google mail or something similar, you might want to use oauth instead:
```php
use Webklex\PHPIMAP\Client;
use Webklex\PHPIMAP\Clientmanager;

$cm = new Clientmanager();

/** @var \Webklex\PHPIMAP\Client $client */
$client = new Client([
$client = $cm->make([
'host' => 'imap.gmail.com',
'port' => 993,
'encryption' => 'ssl',
Expand Down
11 changes: 11 additions & 0 deletions src/ClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public function __call($method, $parameters) {
return call_user_func_array($callable, $parameters);
}

/**
* Safely create a new client instance which is not listed in accounts
* @param array $config
*
* @return Client
* @throws Exceptions\MaskNotFoundException
*/
public function make($config) {
return new Client($config);
}

/**
* Get a dotted config parameter
* @param string $key
Expand Down

0 comments on commit 13e76da

Please sign in to comment.