@@ -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 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | $quit = true; |
74 | 74 | $output = "Closing EmberDb command line client.\n\n"; |
75 | 75 | } else { |
76 | - Logger::log("Starting execution of '" . $inputLine . "'.\n"); |
|
76 | + Logger::log("Starting execution of '".$inputLine."'.\n"); |
|
77 | 77 | $output = $this->parser->execute($inputLine); |
78 | 78 | Logger::log("Execution finished.\n\n"); |
79 | 79 | } |
@@ -75,18 +75,18 @@ |
||
75 | 75 | |
76 | 76 | // If both are a scalar ... |
77 | 77 | if ($this->isScalar($filterValue) && $this->isScalar($entryValue)) { |
78 | - Logger::log("query:" . $filterValue . " and entry:" . $entryValue . " are both scalars.\n"); |
|
78 | + Logger::log("query:".$filterValue." and entry:".$entryValue." are both scalars.\n"); |
|
79 | 79 | $isMatch = $filterValue === $entryValue; |
80 | 80 | } |
81 | 81 | // If both are a list ... |
82 | 82 | if ($this->isList($filterValue) && $this->isList($entryValue)) { |
83 | - Logger::log("query:" . json_encode($filterValue) . " and entry:" . json_encode($entryValue) . " are both lists.\n"); |
|
83 | + Logger::log("query:".json_encode($filterValue)." and entry:".json_encode($entryValue)." are both lists.\n"); |
|
84 | 84 | $isMatch = $filterValue === $entryValue; |
85 | 85 | } |
86 | 86 | |
87 | 87 | // If both are a document ... |
88 | 88 | if ($this->isDocument($filterValue) && $this->isDocument($entryValue)) { |
89 | - Logger::log("query:" . json_encode($filterValue) . " and entry:" . json_encode($entryValue) . " are both documents.\n"); |
|
89 | + Logger::log("query:".json_encode($filterValue)." and entry:".json_encode($entryValue)." are both documents.\n"); |
|
90 | 90 | |
91 | 91 | // If filter is an operator ... |
92 | 92 | if ($this->isOperator($filterValue)) { |
@@ -74,8 +74,7 @@ |
||
74 | 74 | |
75 | 75 | $this->documentManager->insert($collection, $document); |
76 | 76 | $output .= "Inserted document in the $collection collection.\n"; |
77 | - } |
|
78 | - catch (Exception $exception) { |
|
77 | + } catch (Exception $exception) { |
|
79 | 78 | $output .= "Error: ".$exception->getMessage()."\n"; |
80 | 79 | } |
81 | 80 | break; |
@@ -168,6 +168,9 @@ |
||
168 | 168 | |
169 | 169 | |
170 | 170 | |
171 | + /** |
|
172 | + * @param resource $file |
|
173 | + */ |
|
171 | 174 | private function aquireReadLock($file) |
172 | 175 | { |
173 | 176 | $lockAquired = flock($file, LOCK_SH | LOCK_NB); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $this->name = $name; |
49 | 49 | $this->path = $path; |
50 | - $this->metaData = new MetaData($path . '/' . $name . 'meta.edb'); |
|
50 | + $this->metaData = new MetaData($path.'/'.$name.'meta.edb'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | |
157 | 157 | private function getCollectionFilePath() |
158 | 158 | { |
159 | - return $this->path . '/' . $this->name . '.edb'; |
|
159 | + return $this->path.'/'.$this->name.'.edb'; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | 163 | |
164 | 164 | private function createId(): string |
165 | 165 | { |
166 | - return $id = time() . '-' . mt_rand(1000, 9999); |
|
166 | + return $id = time().'-'.mt_rand(1000, 9999); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $fileName = $argv[1]; |
4 | -$filePath = __DIR__ . '/data/' . $fileName; |
|
4 | +$filePath = __DIR__.'/data/'.$fileName; |
|
5 | 5 | $file = fopen($filePath, 'w'); |
6 | 6 | |
7 | 7 | $isLocked = flock($file, LOCK_EX); |
@@ -25,9 +25,9 @@ |
||
25 | 25 | use EmberDb\DocumentManager; |
26 | 26 | use EmberDb\Logger; |
27 | 27 | |
28 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
28 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
29 | 29 | |
30 | -Logger::setup(__DIR__ . '/../log/emberdb-debug.log'); |
|
30 | +Logger::setup(__DIR__.'/../log/emberdb-debug.log'); |
|
31 | 31 | |
32 | 32 | $car = new Document([ |
33 | 33 | 'license-number' => 'HH-DS 1243', |