| Conditions | 11 |
| Paths | 9 |
| Total Lines | 31 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 18 | public function __construct($config) |
||
| 19 | { |
||
| 20 | if (!is_array($config)) { |
||
| 21 | throw new PotatoException("Database Config must be an array"); |
||
| 22 | } |
||
| 23 | |||
| 24 | if (!isset($config['type']) || empty($config['type'])) { |
||
| 25 | throw new PotatoException("You must specify a database type in the config"); |
||
| 26 | } |
||
| 27 | |||
| 28 | if (!isset($config['database']) || empty($config['database'])) { |
||
| 29 | throw new PotatoException("You must provide a database in the config"); |
||
| 30 | } |
||
| 31 | |||
| 32 | $type = strtolower($config['type']); |
||
| 33 | switch ($type) { |
||
| 34 | case 'sqlite': |
||
| 35 | self::$conn = $this->connectSQLite($config); |
||
| 36 | break; |
||
| 37 | case 'mysql': |
||
| 38 | |||
| 39 | break; |
||
| 40 | case 'postgres': |
||
| 41 | case 'pgssql': |
||
| 42 | |||
| 43 | break; |
||
| 44 | case 'mongo': |
||
| 45 | |||
| 46 | break; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 79 |