@@ -100,8 +100,7 @@ discard block |
||
100 | 100 | $default = $this->Config->getDefault(); |
101 | 101 | |
102 | 102 | $name = is_null($default) ? |
103 | - @end(array_keys($configs)) : |
|
104 | - $this->Config->getDefault(); |
|
103 | + @end(array_keys($configs)) : $this->Config->getDefault(); |
|
105 | 104 | |
106 | 105 | self::open($name); |
107 | 106 | } |
@@ -132,7 +131,7 @@ discard block |
||
132 | 131 | } catch (\Exception $e) { |
133 | 132 | throw $e; |
134 | 133 | } |
135 | - } else { |
|
134 | + }else { |
|
136 | 135 | |
137 | 136 | throw new \Exception("This connection isn't actived."); |
138 | 137 | } |
@@ -41,7 +41,9 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function initialize($config = null) |
43 | 43 | { |
44 | - if (!self::$_instance) self::$_instance = new ConnectionManager(); |
|
44 | + if (!self::$_instance) { |
|
45 | + self::$_instance = new ConnectionManager(); |
|
46 | + } |
|
45 | 47 | |
46 | 48 | if (is_callable($config)) { |
47 | 49 | |
@@ -63,9 +65,15 @@ discard block |
||
63 | 65 | { |
64 | 66 | $instance = self::$_instance; |
65 | 67 | |
66 | - if (!is_string($connectionName) || empty($connectionName)) throw new \Exception("Invalid connection name."); |
|
67 | - if (!$instance->hasConnection($connectionName)) throw new \Exception("The connection name $connectionName is not set."); |
|
68 | - if ($instance->hasOpen($connectionName)) throw new \Exception('This connection is actived.'); |
|
68 | + if (!is_string($connectionName) || empty($connectionName)) { |
|
69 | + throw new \Exception("Invalid connection name."); |
|
70 | + } |
|
71 | + if (!$instance->hasConnection($connectionName)) { |
|
72 | + throw new \Exception("The connection name $connectionName is not set."); |
|
73 | + } |
|
74 | + if ($instance->hasOpen($connectionName)) { |
|
75 | + throw new \Exception('This connection is actived.'); |
|
76 | + } |
|
69 | 77 | |
70 | 78 | $instance->_currentConnectionName = $connectionName; |
71 | 79 | |
@@ -95,7 +103,9 @@ discard block |
||
95 | 103 | if (empty($this->currentConnection)) { |
96 | 104 | $configs = ($this->Config) ? $this->Config->getConfigs() : null; |
97 | 105 | |
98 | - if (count($configs) == 0) throw new \Exception('No connections are available.'); |
|
106 | + if (count($configs) == 0) { |
|
107 | + throw new \Exception('No connections are available.'); |
|
108 | + } |
|
99 | 109 | |
100 | 110 | $default = $this->Config->getDefault(); |
101 | 111 | |
@@ -121,9 +131,13 @@ discard block |
||
121 | 131 | { |
122 | 132 | $instance = self::initialize(); |
123 | 133 | |
124 | - if (!is_string($connectionName)) throw new \Exception("Invalid connection name."); |
|
134 | + if (!is_string($connectionName)) { |
|
135 | + throw new \Exception("Invalid connection name."); |
|
136 | + } |
|
125 | 137 | |
126 | - if (!$instance->hasConnection($connectionName)) throw new \Exception("The connection name $connectionName is not set."); |
|
138 | + if (!$instance->hasConnection($connectionName)) { |
|
139 | + throw new \Exception("The connection name $connectionName is not set."); |
|
140 | + } |
|
127 | 141 | |
128 | 142 | if (!$instance->hasOpen($connectionName)) { |
129 | 143 | if ($open) { |
@@ -154,7 +168,9 @@ discard block |
||
154 | 168 | */ |
155 | 169 | public function getAllActive() |
156 | 170 | { |
157 | - if (!$this->hasInstance()) throw new \Exception('This instance isnt\'t initialized'); |
|
171 | + if (!$this->hasInstance()) { |
|
172 | + throw new \Exception('This instance isnt\'t initialized'); |
|
173 | + } |
|
158 | 174 | |
159 | 175 | return $this->connections; |
160 | 176 | } |