@@ -39,14 +39,17 @@ |
||
| 39 | 39 | switch ($command) { |
| 40 | 40 | case 'insert': |
| 41 | 41 | try { |
| 42 | - if (count($parameters) != 2) throw new Exception('Incorrect number of parameters for command "insert".'); |
|
| 42 | + if (count($parameters) != 2) { |
|
| 43 | + throw new Exception('Incorrect number of parameters for command "insert".'); |
|
| 44 | + } |
|
| 43 | 45 | $collection = $parameters[0]; |
| 44 | 46 | $document = json_decode($parameters[1], true); |
| 45 | - if ($document === null) throw new Exception('The description of the document is not a valid json.'); |
|
| 47 | + if ($document === null) { |
|
| 48 | + throw new Exception('The description of the document is not a valid json.'); |
|
| 49 | + } |
|
| 46 | 50 | $this->documentManager->insert($collection, $document); |
| 47 | 51 | $output .= "Inserted document in the $collection collection.\n"; |
| 48 | - } |
|
| 49 | - catch (Exception $exception) { |
|
| 52 | + } catch (Exception $exception) { |
|
| 50 | 53 | $output .= "Error: ".$exception->getMessage()."\n"; |
| 51 | 54 | } |
| 52 | 55 | break; |
@@ -16,10 +16,13 @@ |
||
| 16 | 16 | public function getDatabasePath() |
| 17 | 17 | { |
| 18 | 18 | try { |
| 19 | - if (!array_key_exists('database', $this->config)) throw new Exception('The config has no entry with key "database".'); |
|
| 20 | - if (!array_key_exists('path', $this->config['database'])) throw new Exception('The config has no entry with key "database/path".'); |
|
| 21 | - } |
|
| 22 | - catch (Exception $exception) { |
|
| 19 | + if (!array_key_exists('database', $this->config)) { |
|
| 20 | + throw new Exception('The config has no entry with key "database".'); |
|
| 21 | + } |
|
| 22 | + if (!array_key_exists('path', $this->config['database'])) { |
|
| 23 | + throw new Exception('The config has no entry with key "database/path".'); |
|
| 24 | + } |
|
| 25 | + } catch (Exception $exception) { |
|
| 23 | 26 | throw new Exception('Missing config: '.$exception->getMessage()); |
| 24 | 27 | } |
| 25 | 28 | |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use EmberDb\DocumentManager; |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 5 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | $car = array( |
| 8 | 8 | 'license-number' => 'HH-DS 1243', |