Skip to content

Commit

Permalink
小修改
Browse files Browse the repository at this point in the history
  • Loading branch information
linvanda committed May 15, 2019
1 parent 4fc3dc4 commit 630295e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Connector/CoConnectorBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ class CoConnectorBuilder implements IConnectorBuilder
* @param array $readConfigs
* @throws \Exception
*/
public function __construct(DBConfig $writeConfig, array $readConfigs)
public function __construct(DBConfig $writeConfig = null, array $readConfigs = [])
{
foreach ($readConfigs as $config) {
if (!($config instanceof DBConfig)) {
throw new \Exception("error DBConfig object");
}
}

$this->writeConfig = $writeConfig;
$this->readConfigs = $readConfigs;
}
Expand All @@ -35,6 +29,10 @@ public function build(string $connType = 'write'): IConnector
/** @var DBConfig */
$config = $connType == 'read' ? $this->getReadConfig() : $this->writeConfig;

if (!($config instanceof DBConfig)) {
return null;
}

return new CoConnector($config->host, $config->user, $config->password, $config->database, $config->port, $config->timeout, $config->charset, $config->autoConnect);
}

Expand Down

0 comments on commit 630295e

Please sign in to comment.