Completed
Push — master ( 83f3f2...00f539 )
by Filippo
08:46 queued 06:03
created
src/EoC/Info/AttachmentInfo.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,10 +45,11 @@
 block discarded – undo
45 45
    * @retval string|bool The codec name or `false` if the attachment is not compressed.
46 46
    */
47 47
   public function getContentEncoding() {
48
-    if ($this->response->hasHeaderField(Response::CONTENT_ENCODING_HF))
49
-      return $this->response->getHeaderFieldValue(Response::CONTENT_ENCODING_HF);
50
-    else
51
-      return FALSE;
48
+    if ($this->response->hasHeaderField(Response::CONTENT_ENCODING_HF)) {
49
+          return $this->response->getHeaderFieldValue(Response::CONTENT_ENCODING_HF);
50
+    } else {
51
+          return FALSE;
52
+    }
52 53
   }
53 54
 
54 55
 
Please login to merge, or discard this patch.
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/Doc/Doc.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,8 +54,9 @@  discard block
 block discarded – undo
54 54
   public function getAttachments() {
55 55
     $attachments = [];
56 56
 
57
-    foreach ($this->meta[self::ATTACHMENTS] as $attachment)
58
-      $attachments[] = Attachment::fromArray($attachment);
57
+    foreach ($this->meta[self::ATTACHMENTS] as $attachment) {
58
+          $attachments[] = Attachment::fromArray($attachment);
59
+    }
59 60
 
60 61
     return $attachments;
61 62
   }
@@ -75,13 +76,15 @@  discard block
 block discarded – undo
75 76
    * @todo To be documented.
76 77
    */
77 78
   public function removeAttachment($name) {
78
-    if ($this->isMetadataPresent(self::ATTACHMENTS))
79
-      if (array_key_exists($name, $this->meta[self::ATTACHMENTS]))
79
+    if ($this->isMetadataPresent(self::ATTACHMENTS)) {
80
+          if (array_key_exists($name, $this->meta[self::ATTACHMENTS]))
80 81
         unset($this->meta[self::ATTACHMENTS][$name]);
81
-      else
82
-        throw new \Exception("Can't find `$name` attachment in the document.");
83
-    else
84
-      throw new \Exception("The document doesn't have any attachment.");
82
+    } else {
83
+              throw new \Exception("Can't find `$name` attachment in the document.");
84
+      }
85
+    else {
86
+          throw new \Exception("The document doesn't have any attachment.");
87
+    }
85 88
   }
86 89
 
87 90
 
Please login to merge, or discard this patch.
src/EoC/Doc/TDoc.php 1 patch
Braces   +17 added lines, -12 removed lines patch added patch discarded remove patch
@@ -48,19 +48,22 @@  discard block
 block discarded – undo
48 48
 
49 49
 
50 50
   public function setMetadata($name, $value, $override = TRUE, $allowNull = TRUE) {
51
-    if (is_null($value) && !$allowNull)
52
-      return;
51
+    if (is_null($value) && !$allowNull) {
52
+          return;
53
+    }
53 54
 
54
-    if ($this->isMetadataPresent($name) && !$override)
55
-      return;
55
+    if ($this->isMetadataPresent($name) && !$override) {
56
+          return;
57
+    }
56 58
 
57 59
     $this->meta[$name] = $value;
58 60
   }
59 61
 
60 62
 
61 63
   public function unsetMetadata($name) {
62
-    if (array_key_exists($name, $this->meta))
63
-      unset($this->meta[$name]);
64
+    if (array_key_exists($name, $this->meta)) {
65
+          unset($this->meta[$name]);
66
+    }
64 67
   }
65 68
 
66 69
 
@@ -94,9 +97,9 @@  discard block
 block discarded – undo
94 97
     if (Helper\ArrayHelper::isAssociative($array)) {
95 98
       $this->meta = array_merge($this->meta, $array);
96 99
       $this->fixDocId();
100
+    } else {
101
+          throw new \InvalidArgumentException("\$array must be an associative array.");
97 102
     }
98
-    else
99
-      throw new \InvalidArgumentException("\$array must be an associative array.");
100 103
   }
101 104
 
102 105
 
@@ -147,8 +150,9 @@  discard block
 block discarded – undo
147 150
 
148 151
 
149 152
   public function unsetId() {
150
-    if ($this->isMetadataPresent('_id'))
151
-      unset($this->meta['_id']);
153
+    if ($this->isMetadataPresent('_id')) {
154
+          unset($this->meta['_id']);
155
+    }
152 156
   }
153 157
 
154 158
 
@@ -168,8 +172,9 @@  discard block
 block discarded – undo
168 172
 
169 173
 
170 174
   public function unsetRev() {
171
-    if ($this->isMetadataPresent('_rev'))
172
-      unset($this->meta['_rev']);
175
+    if ($this->isMetadataPresent('_rev')) {
176
+          unset($this->meta['_rev']);
177
+    }
173 178
   }
174 179
 
175 180
 }
176 181
\ No newline at end of file
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.