Completed
Push — master ( 3a3340...4bd61d )
by Filippo
03:57
created
src/EoC/Info/DbInfo.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@
 block discarded – undo
82 82
       $this->purgeSeq = $info['purge_seq'];
83 83
       $this->compactRunning = $info['compact_running'];
84 84
       $this->committedUpdateSeq = $info['committed_update_seq'];
85
+    } else {
86
+          throw new \Exception("\$info must be an associative array.");
85 87
     }
86
-    else
87
-      throw new \Exception("\$info must be an associative array.");
88 88
   }
89 89
 
90 90
 
Please login to merge, or discard this patch.
src/EoC/Doc/LocalDoc.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@
 block discarded – undo
25 25
    * @brief Removes `_local/` from he document identifier.
26 26
    */
27 27
   protected function fixDocId() {
28
-    if (isset($this->meta['_id']))
29
-      $this->meta['_id'] = preg_replace('%\A_local/%m', "", $this->meta['_id']);
28
+    if (isset($this->meta['_id'])) {
29
+          $this->meta['_id'] = preg_replace('%\A_local/%m', "", $this->meta['_id']);
30
+    }
30 31
   }
31 32
 
32 33
 
Please login to merge, or discard this patch.
src/EoC/Doc/DesignDoc.php 1 patch
Braces   +55 added lines, -46 removed lines patch added patch discarded remove patch
@@ -63,8 +63,9 @@  discard block
 block discarded – undo
63 63
    * @brief Removes `_design/` from he document identifier.
64 64
    */
65 65
   protected function fixDocId() {
66
-    if (isset($this->meta['_id']))
67
-      $this->meta['_id'] = preg_replace('%\A_design/%m', "", $this->meta['_id']);
66
+    if (isset($this->meta['_id'])) {
67
+          $this->meta['_id'] = preg_replace('%\A_design/%m', "", $this->meta['_id']);
68
+    }
68 69
   }
69 70
 
70 71
 
@@ -94,8 +95,9 @@  discard block
 block discarded – undo
94 95
    */
95 96
   public function resetHandlers() {
96 97
     foreach ($this->sections as $name => $value) {
97
-      if (array_key_exists($name, $this->meta))
98
-        unset($this->meta[$name]);
98
+      if (array_key_exists($name, $this->meta)) {
99
+              unset($this->meta[$name]);
100
+      }
99 101
     }
100 102
   }
101 103
 
@@ -108,16 +110,17 @@  discard block
 block discarded – undo
108 110
    */
109 111
   public function getHandlerAttributes($section, $name = "") {
110 112
     if (empty($name)) { // The handler doesn't have a name.
111
-      if (array_key_exists($section, $this->meta))
112
-        return $this->meta[$section];
113
-      else
114
-        throw new \Exception(sprintf("Can't find '%s' handler in the design document.", $section));
115
-    }
116
-    else { // The handler has a name.
117
-      if (@array_key_exists($name, $this->meta[$section]))
118
-        return $this->meta[$section][$name];
119
-      else
120
-        throw new \Exception(sprintf("Can't find '%s' handler in the design document '%s' section.", $name, $section));
113
+      if (array_key_exists($section, $this->meta)) {
114
+              return $this->meta[$section];
115
+      } else {
116
+              throw new \Exception(sprintf("Can't find '%s' handler in the design document.", $section));
117
+      }
118
+    } else { // The handler has a name.
119
+      if (@array_key_exists($name, $this->meta[$section])) {
120
+              return $this->meta[$section][$name];
121
+      } else {
122
+              throw new \Exception(sprintf("Can't find '%s' handler in the design document '%s' section.", $name, $section));
123
+      }
121 124
     }
122 125
   }
123 126
 
@@ -133,22 +136,25 @@  discard block
 block discarded – undo
133 136
     $section = $handler->getSection();
134 137
 
135 138
     if (property_exists($handler, "name")) {
136
-      if (!$handler->isConsistent())
137
-        throw new \Exception(sprintf("The '%s' handler '%s' is not consistent.", $section, $handler->name));
138
-
139
-      if (@array_key_exists($handler->name, $this->meta[$section]))
140
-        throw new \Exception(sprintf("The '%s' handler '%s' already exists.", $section, $handler->name));
141
-      else
142
-        $this->meta[$section][$handler->name] = $handler->asArray();
143
-    }
144
-    else {
145
-      if (!$handler->isConsistent())
146
-        throw new \Exception(sprintf("The '%s' handler is not consistent.", $section));
147
-
148
-      if (array_key_exists($section, $this->meta))
149
-        throw new \Exception(sprintf("The '%s' handler already exists.", $section));
150
-      else
151
-        $this->meta[$section] = $handler;
139
+      if (!$handler->isConsistent()) {
140
+              throw new \Exception(sprintf("The '%s' handler '%s' is not consistent.", $section, $handler->name));
141
+      }
142
+
143
+      if (@array_key_exists($handler->name, $this->meta[$section])) {
144
+              throw new \Exception(sprintf("The '%s' handler '%s' already exists.", $section, $handler->name));
145
+      } else {
146
+              $this->meta[$section][$handler->name] = $handler->asArray();
147
+      }
148
+    } else {
149
+      if (!$handler->isConsistent()) {
150
+              throw new \Exception(sprintf("The '%s' handler is not consistent.", $section));
151
+      }
152
+
153
+      if (array_key_exists($section, $this->meta)) {
154
+              throw new \Exception(sprintf("The '%s' handler already exists.", $section));
155
+      } else {
156
+              $this->meta[$section] = $handler;
157
+      }
152 158
     }
153 159
   }
154 160
 
@@ -163,16 +169,17 @@  discard block
 block discarded – undo
163 169
    */
164 170
   public function removeHandler($section, $name = "") {
165 171
     if (empty($name)) { // The handler doesn't have a name.
166
-      if (array_key_exists($section, $this->meta))
167
-        unset($this->meta[$section]);
168
-      else
169
-        throw new \Exception(sprintf("Can't find the '%s' handler.", $section));
170
-    }
171
-    else { // The handler has a name.
172
-      if (@array_key_exists($name, $this->meta[$section]))
173
-        unset($this->meta[$section][$name]);
174
-      else
175
-        throw new \Exception(sprintf("Can't find the '%s' handler '%s'", $section, $name));
172
+      if (array_key_exists($section, $this->meta)) {
173
+              unset($this->meta[$section]);
174
+      } else {
175
+              throw new \Exception(sprintf("Can't find the '%s' handler.", $section));
176
+      }
177
+    } else { // The handler has a name.
178
+      if (@array_key_exists($name, $this->meta[$section])) {
179
+              unset($this->meta[$section][$name]);
180
+      } else {
181
+              throw new \Exception(sprintf("Can't find the '%s' handler '%s'", $section, $name));
182
+      }
176 183
     }
177 184
   }
178 185
 
@@ -190,16 +197,18 @@  discard block
 block discarded – undo
190 197
 
191 198
 
192 199
   public function setLanguage($value) {
193
-    if (!empty($value))
194
-      $this->meta['language'] = strtolower((string)$value);
195
-    else
196
-      throw new \InvalidArgumentException("\$language must be a non-empty string.");
200
+    if (!empty($value)) {
201
+          $this->meta['language'] = strtolower((string)$value);
202
+    } else {
203
+          throw new \InvalidArgumentException("\$language must be a non-empty string.");
204
+    }
197 205
   }
198 206
 
199 207
 
200 208
   public function unsetLanguage() {
201
-    if ($this->isMetadataPresent('language'))
202
-      unset($this->meta['language']);
209
+    if ($this->isMetadataPresent('language')) {
210
+          unset($this->meta['language']);
211
+    }
203 212
   }
204 213
 
205 214
   //! @endcond
Please login to merge, or discard this patch.
src/EoC/Doc/DocRef.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,10 +59,11 @@
 block discarded – undo
59 59
 
60 60
 
61 61
   public function setId($value) {
62
-    if (!empty($value))
63
-      $this->id = (string)$value;
64
-    else
65
-      throw new \Exception("\$id must be a non-empty string.");
62
+    if (!empty($value)) {
63
+          $this->id = (string)$value;
64
+    } else {
65
+          throw new \Exception("\$id must be a non-empty string.");
66
+    }
66 67
   }
67 68
 
68 69
 
Please login to merge, or discard this patch.
src/EoC/Doc/Attachment/Attachment.php 1 patch
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@  discard block
 block discarded – undo
41 41
     $instance = new self();
42 42
 
43 43
     if (file_exists($fileName)) {
44
-      if (is_dir($fileName))
45
-        throw new \Exception("The file $fileName is a directory.");
44
+      if (is_dir($fileName)) {
45
+              throw new \Exception("The file $fileName is a directory.");
46
+      }
46 47
 
47 48
       $instance->name = basename($fileName);
48 49
 
@@ -58,14 +59,15 @@  discard block
 block discarded – undo
58 59
         finfo_close($finfo);
59 60
         fclose($fd);
60 61
 
61
-        if ($instance->data === FALSE)
62
-          throw new \Exception("Error reading the file $fileName.");
62
+        if ($instance->data === FALSE) {
63
+                  throw new \Exception("Error reading the file $fileName.");
64
+        }
65
+      } else {
66
+              throw new \Exception("Cannot open the file $fileName.");
63 67
       }
64
-      else
65
-        throw new \Exception("Cannot open the file $fileName.");
68
+    } else {
69
+          throw new \Exception("The file $fileName doesn't exist.");
66 70
     }
67
-    else
68
-      throw new \Exception("The file $fileName doesn't exist.");
69 71
 
70 72
     return $instance;
71 73
   }
@@ -101,11 +103,12 @@  discard block
 block discarded – undo
101 103
       $bytes = fwrite($fd, $this->data);
102 104
       fclose($fd);
103 105
 
104
-      if ($bytes === FALSE)
105
-        throw new \Exception("Error writing the file `$this->name`.");
106
+      if ($bytes === FALSE) {
107
+              throw new \Exception("Error writing the file `$this->name`.");
108
+      }
109
+    } else {
110
+          throw new \Exception("Cannot create the file `$this->name`.");
106 111
     }
107
-    else
108
-      throw new \Exception("Cannot create the file `$this->name`.");
109 112
   }
110 113
 
111 114
 
Please login to merge, or discard this patch.
src/EoC/Generator/UUID.php 1 patch
Braces   +34 added lines, -25 removed lines patch added patch discarded remove patch
@@ -131,17 +131,18 @@  discard block
 block discarded – undo
131 131
 
132 132
   /* Auto-detect UUID format */
133 133
   static private function detectFormat($src) {
134
-    if (is_string($src))
135
-      return self::FMT_STRING;
136
-    else if (is_array($src)) {
134
+    if (is_string($src)) {
135
+          return self::FMT_STRING;
136
+    } else if (is_array($src)) {
137 137
       $len = count($src);
138
-      if ($len == 1 || ($len % 2) == 0)
139
-        return $len;
140
-      else
141
-        return (-1);
138
+      if ($len == 1 || ($len % 2) == 0) {
139
+              return $len;
140
+      } else {
141
+              return (-1);
142
+      }
143
+    } else {
144
+          return self::FMT_BINARY;
142 145
     }
143
-    else
144
-      return self::FMT_BINARY;
145 146
   }
146 147
 
147 148
   /*
@@ -151,8 +152,9 @@  discard block
 block discarded – undo
151 152
   static public function generate($type, $fmt = self::FMT_BYTE,
152 153
                                   $node = "", $ns = "") {
153 154
     $func = self::$m_generate[$type];
154
-    if (!isset($func))
155
-      return null;
155
+    if (!isset($func)) {
156
+          return null;
157
+    }
156 158
     $conv = self::$m_convert[self::FMT_FIELD][$fmt];
157 159
 
158 160
     $uuid = self::$func($ns, $node);
@@ -164,8 +166,9 @@  discard block
 block discarded – undo
164 166
    */
165 167
   static public function convert($uuid, $from, $to) {
166 168
     $conv = self::$m_convert[$from][$to];
167
-    if (!isset($conv))
168
-      return ($uuid);
169
+    if (!isset($conv)) {
170
+          return ($uuid);
171
+    }
169 172
 
170 173
     return (self::$conv($uuid));
171 174
   }
@@ -181,8 +184,9 @@  discard block
 block discarded – undo
181 184
     $uuid['time_low'] = mt_rand(0, 0xffff) + (mt_rand(0, 0xffff) << 16);
182 185
     $uuid['time_mid'] = mt_rand(0, 0xffff);
183 186
     $uuid['clock_seq_low'] = mt_rand(0, 255);
184
-    for ($i = 0; $i < 6; $i++)
185
-      $uuid['node'][$i] = mt_rand(0, 255);
187
+    for ($i = 0; $i < 6; $i++) {
188
+          $uuid['node'][$i] = mt_rand(0, 255);
189
+    }
186 190
     return ($uuid);
187 191
   }
188 192
 
@@ -205,8 +209,9 @@  discard block
 block discarded – undo
205 209
     /* Hash the namespace and node and convert to a byte array */
206 210
     $val = $hash($raw, true);
207 211
     $tmp = unpack('C16', $val);
208
-    foreach (array_keys($tmp) as $key)
209
-      $byte[$key - 1] = $tmp[$key];
212
+    foreach (array_keys($tmp) as $key) {
213
+          $byte[$key - 1] = $tmp[$key];
214
+    }
210 215
 
211 216
     /* Convert byte array to a field array */
212 217
     $field = self::conv_byte2field($byte);
@@ -264,8 +269,9 @@  discard block
 block discarded – undo
264 269
       * Node should be set to the 48-bit IEEE node identifier, but
265 270
       * we leave it for the user to supply the node.
266 271
       */
267
-    for ($i = 0; $i < 6; $i++)
268
-      $uuid['node'][$i] = ord(substr($node, $i, 1));
272
+    for ($i = 0; $i < 6; $i++) {
273
+          $uuid['node'][$i] = ord(substr($node, $i, 1));
274
+    }
269 275
 
270 276
     return ($uuid);
271 277
   }
@@ -283,8 +289,9 @@  discard block
 block discarded – undo
283 289
     $uuid[8] = $src['clock_seq_hi'];
284 290
     $uuid[9] = $src['clock_seq_low'];
285 291
 
286
-    for ($i = 0; $i < 6; $i++)
287
-      $uuid[10+$i] = $src['node'][$i];
292
+    for ($i = 0; $i < 6; $i++) {
293
+          $uuid[10+$i] = $src['node'][$i];
294
+    }
288 295
 
289 296
     return ($uuid);
290 297
   }
@@ -313,8 +320,9 @@  discard block
 block discarded – undo
313 320
     $field['clock_seq_hi'] = $uuid[8];
314 321
     $field['clock_seq_low'] = $uuid[9];
315 322
 
316
-    for ($i = 0; $i < 6; $i++)
317
-      $field['node'][$i] = $uuid[10+$i];
323
+    for ($i = 0; $i < 6; $i++) {
324
+          $field['node'][$i] = $uuid[10+$i];
325
+    }
318 326
     return ($field);
319 327
   }
320 328
 
@@ -338,8 +346,9 @@  discard block
 block discarded – undo
338 346
     $field['time_hi'] = ($parts[2]);
339 347
     $field['clock_seq_hi'] = ($parts[3] & 0xff00) >> 8;
340 348
     $field['clock_seq_low'] = $parts[3] & 0x00ff;
341
-    for ($i = 0; $i < 6; $i++)
342
-      $field['node'][$i] = $parts[4+$i];
349
+    for ($i = 0; $i < 6; $i++) {
350
+          $field['node'][$i] = $parts[4+$i];
351
+    }
343 352
 
344 353
     return ($field);
345 354
   }
Please login to merge, or discard this patch.
src/EoC/Handler/ViewHandler.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -144,8 +144,9 @@  discard block
 block discarded – undo
144 144
   public static function checkFn($fnImpl, $fnDef, $fnRegex) {
145 145
     Lint::checkSourceCode($fnImpl);
146 146
 
147
-    if (!preg_match($fnRegex, $fnImpl))
148
-      throw new \Exception("The \$closure must be defined like: $fnDef");
147
+    if (!preg_match($fnRegex, $fnImpl)) {
148
+          throw new \Exception("The \$closure must be defined like: $fnDef");
149
+    }
149 150
   }
150 151
 
151 152
 
@@ -153,14 +154,17 @@  discard block
 block discarded – undo
153 154
     $view = [];
154 155
     $view['map'] = $this->mapFn;
155 156
 
156
-    if (!empty($this->language))
157
-      $view['language'] = $this->language;
157
+    if (!empty($this->language)) {
158
+          $view['language'] = $this->language;
159
+    }
158 160
 
159
-    if (!empty($this->reduceFn))
160
-      $view['reduce'] = $this->reduceFn;
161
+    if (!empty($this->reduceFn)) {
162
+          $view['reduce'] = $this->reduceFn;
163
+    }
161 164
 
162
-    if (!empty($this->options))
163
-      $view['options'] = $this->options;
165
+    if (!empty($this->options)) {
166
+          $view['options'] = $this->options;
167
+    }
164 168
 
165 169
     return $view;
166 170
   }
@@ -225,8 +229,9 @@  discard block
 block discarded – undo
225 229
   public function setMapFn($value) {
226 230
     $fn = stripslashes((string)$value);
227 231
 
228
-    if ($this->language == "php")
229
-      self::checkFn($fn, self::MAP_DEFINITION, self::MAP_REGEX);
232
+    if ($this->language == "php") {
233
+          self::checkFn($fn, self::MAP_DEFINITION, self::MAP_REGEX);
234
+    }
230 235
 
231 236
     $this->mapFn = $fn;
232 237
   }
@@ -240,8 +245,9 @@  discard block
 block discarded – undo
240 245
   public function setReduceFn($value) {
241 246
     $fn = stripslashes((string)$value);
242 247
 
243
-    if ($this->language == "php")
244
-      self::checkFn($fn, self::REDUCE_DEFINITION, self::REDUCE_REGEX);
248
+    if ($this->language == "php") {
249
+          self::checkFn($fn, self::REDUCE_DEFINITION, self::REDUCE_REGEX);
250
+    }
245 251
 
246 252
     $this->reduceFn = $fn;
247 253
   }
Please login to merge, or discard this patch.
src/EoC/Opt/ViewQueryOpts.php 1 patch
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,8 +36,9 @@  discard block
 block discarded – undo
36 36
    * @attention Chainable.
37 37
    */
38 38
   public function unsetOpt($name) {
39
-    if (array_key_exists($name, $this->options))
40
-      unset($this->options['name']);
39
+    if (array_key_exists($name, $this->options)) {
40
+          unset($this->options['name']);
41
+    }
41 42
 
42 43
     return $this;
43 44
   }
@@ -137,10 +138,11 @@  discard block
 block discarded – undo
137 138
    * @attention Chainable.
138 139
    */
139 140
   public function setLimit($value) {
140
-    if (is_int($value) && $value >= 0)
141
-      $this->options["limit"] = $value;
142
-    else
143
-      throw new \Exception("\$value must be a non-negative integer.");
141
+    if (is_int($value) && $value >= 0) {
142
+          $this->options["limit"] = $value;
143
+    } else {
144
+          throw new \Exception("\$value must be a non-negative integer.");
145
+    }
144 146
 
145 147
     return $this;
146 148
   }
@@ -173,9 +175,9 @@  discard block
 block discarded – undo
173 175
     if (is_int($value) && $value > 0) {
174 176
       $this->options["group"] = "false"; // This parameter is used only if 'group' is 'false'.
175 177
       $this->options["group_level"] = $value;
178
+    } else {
179
+          throw new \Exception("\$value must be a positive integer.");
176 180
     }
177
-    else
178
-      throw new \Exception("\$value must be a positive integer.");
179 181
 
180 182
     return $this;
181 183
   }
@@ -311,10 +313,11 @@  discard block
 block discarded – undo
311 313
    * @attention Chainable.
312 314
    */
313 315
   public function skipDocs($number) {
314
-    if (is_int($number) && $number > 0)
315
-      $this->options["skip"] = $number;
316
-    else
317
-      throw new \Exception("\$number must be a positive integer.");
316
+    if (is_int($number) && $number > 0) {
317
+          $this->options["skip"] = $number;
318
+    } else {
319
+          throw new \Exception("\$number must be a positive integer.");
320
+    }
318 321
 
319 322
     return $this;
320 323
   }
Please login to merge, or discard this patch.
src/EoC/Doc/AbstractDoc.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -149,8 +149,9 @@  discard block
 block discarded – undo
149 149
 
150 150
 
151 151
   public function unsetId() {
152
-    if ($this->isMetadataPresent('_id'))
153
-      unset($this->meta['_id']);
152
+    if ($this->isMetadataPresent('_id')) {
153
+          unset($this->meta['_id']);
154
+    }
154 155
   }
155 156
 
156 157
 
@@ -170,8 +171,9 @@  discard block
 block discarded – undo
170 171
 
171 172
 
172 173
   public function unsetRev() {
173
-    if ($this->isMetadataPresent('_rev'))
174
-      unset($this->meta['_rev']);
174
+    if ($this->isMetadataPresent('_rev')) {
175
+          unset($this->meta['_rev']);
176
+    }
175 177
   }
176 178
 
177 179
   //! @endcond
Please login to merge, or discard this patch.