Completed
Branch master (c5ac33)
by Siad
10:40
created
src/Cache/Storage/Adapter/Couchbase.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,9 +170,9 @@
 block discarded – undo
170 170
     /**
171 171
      * Set options.
172 172
      *
173
-     * @param array|\Traversable|CouchbaseOptions $options
173
+     * @param CouchbaseOptions $options
174 174
      *
175
-     * @return \CouchbaseCluster
175
+     * @return AbstractAdapter
176 176
      *
177 177
      * @see    getOptions()
178 178
      */
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
     public function __construct($options = null)
69 69
     {
70 70
         if (static::$extCouchbaseMajorVersion === null) {
71
-            $v = (string) phpversion('couchbase');
72
-            static::$extCouchbaseMajorVersion = ($v !== '') ? (int) $v[0] : 0;
71
+            $v = (string)phpversion('couchbase');
72
+            static::$extCouchbaseMajorVersion = ($v !== '') ? (int)$v[0] : 0;
73 73
         }
74 74
         if (static::$extCouchbaseMajorVersion < 2) {
75 75
             throw new Exception\ExtensionNotLoadedException('Need ext/couchbase version >= 2.0.0');
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         parent::__construct($options);
78 78
         // reset initialized flag on update option(s)
79 79
         $initialized = &$this->initialized;
80
-        $this->getEventManager()->attach('option', function () use (&$initialized) {
80
+        $this->getEventManager()->attach('option', function() use (&$initialized) {
81 81
             $initialized = false;
82 82
         });
83 83
     }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     protected function internalSetItem(&$normalizedKey, &$value)
108 108
     {
109 109
         $memc = $this->getCouchbaseResource();
110
-        $internalKey = $this->namespacePrefix.$normalizedKey;
110
+        $internalKey = $this->namespacePrefix . $normalizedKey;
111 111
 
112 112
         try {
113 113
             $memc->upsert($internalKey, $value, ['expiry' => $this->expirationTime()]);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             $this->namespacePrefix = '';
142 142
 
143 143
             if ($namespace !== '') {
144
-                $this->namespacePrefix = $namespace.$options->getNamespaceSeparator();
144
+                $this->namespacePrefix = $namespace . $options->getNamespaceSeparator();
145 145
             }
146 146
 
147 147
             // update initialized flag
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     protected function internalAddItem(&$normalizedKey, &$value)
223 223
     {
224 224
         $memc = $this->getCouchbaseResource();
225
-        $internalKey = $this->namespacePrefix.$normalizedKey;
225
+        $internalKey = $this->namespacePrefix . $normalizedKey;
226 226
         try {
227 227
             $memc->insert($internalKey, $value, ['expiry' => $this->expirationTime()]);
228 228
         } catch (\CouchbaseException $e) {
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
         $namespacedKeyValuePairs = [];
270 270
 
271 271
         foreach ($normalizedKeyValuePairs as $normalizedKey => &$value) {
272
-            $namespacedKeyValuePairs[$this->namespacePrefix.$normalizedKey] = ['value' => &$value];
272
+            $namespacedKeyValuePairs[$this->namespacePrefix . $normalizedKey] = ['value' => &$value];
273 273
         }
274 274
         unset($value);
275 275
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         $result = true;
341 341
 
342 342
         try {
343
-            $memc->remove($this->namespacePrefix.$normalizedKey);
343
+            $memc->remove($this->namespacePrefix . $normalizedKey);
344 344
         } catch (\CouchbaseException $e) {
345 345
             $result = false;
346 346
         }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     protected function namespacesKeys(array &$normalizedKeys)
378 378
     {
379 379
         foreach ($normalizedKeys as &$normalizedKey) {
380
-            $normalizedKey = $this->namespacePrefix.$normalizedKey;
380
+            $normalizedKey = $this->namespacePrefix . $normalizedKey;
381 381
         }
382 382
     }
383 383
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
     protected function internalCheckAndSetItem(&$token, &$normalizedKey, &$value)
399 399
     {
400 400
         $memc = $this->getCouchbaseResource();
401
-        $key = $this->namespacePrefix.$normalizedKey;
401
+        $key = $this->namespacePrefix . $normalizedKey;
402 402
         $success = null;
403 403
         $this->internalGetItem($key, $success, $token);
404 404
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
      */
431 431
     protected function internalGetItem(&$normalizedKey, &$success = null, &$casToken = null)
432 432
     {
433
-        $internalKey = $this->namespacePrefix.$normalizedKey;
433
+        $internalKey = $this->namespacePrefix . $normalizedKey;
434 434
         $memc = $this->getCouchbaseResource();
435 435
 
436 436
         try {
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         $memc = $this->getCouchbaseResource();
468 468
         $expiration = $this->expirationTime();
469 469
         try {
470
-            $memc->replace($this->namespacePrefix.$normalizedKey, $value, ['expiry' => $expiration]);
470
+            $memc->replace($this->namespacePrefix . $normalizedKey, $value, ['expiry' => $expiration]);
471 471
         } catch (\CouchbaseException $e) {
472 472
             $result = false;
473 473
         }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         $redis = $this->getCouchbaseResource();
490 490
         try {
491 491
             $ttl = $this->getOptions()->getTtl();
492
-            $redis->touch($this->namespacePrefix.$normalizedKey, $ttl);
492
+            $redis->touch($this->namespacePrefix . $normalizedKey, $ttl);
493 493
         } catch (\CouchbaseException $e) {
494 494
             if ($e->getCode() === \COUCHBASE_KEY_EEXISTS
495 495
                 || $e->getCode() === \COUCHBASE_KEY_ENOENT
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
     protected function internalHasItem(&$normalizedKey)
515 515
     {
516 516
         $memc = $this->getCouchbaseResource();
517
-        $internalKey = $this->namespacePrefix.$normalizedKey;
517
+        $internalKey = $this->namespacePrefix . $normalizedKey;
518 518
 
519 519
         try {
520 520
             $result = $memc->get($internalKey)->value;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
             }
527 527
         }
528 528
 
529
-        return (bool) $result;
529
+        return (bool)$result;
530 530
     }
531 531
 
532 532
     /**
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
     protected function internalIncrementItem(&$normalizedKey, &$value)
621 621
     {
622 622
         $couchbaseBucket = $this->getCouchbaseResource();
623
-        $internalKey = $this->namespacePrefix.$normalizedKey;
624
-        $value = (int) $value;
623
+        $internalKey = $this->namespacePrefix . $normalizedKey;
624
+        $value = (int)$value;
625 625
         $newValue = false;
626 626
 
627 627
         try {
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
     protected function internalDecrementItem(&$normalizedKey, &$value)
653 653
     {
654 654
         $couchbaseBucket = $this->getCouchbaseResource();
655
-        $internalKey = $this->namespacePrefix.$normalizedKey;
656
-        $value = - (int) $value;
655
+        $internalKey = $this->namespacePrefix . $normalizedKey;
656
+        $value = - (int)$value;
657 657
         $newValue = false;
658 658
 
659 659
         try {
Please login to merge, or discard this patch.
src/Cache/Storage/Adapter/CouchbaseOptions.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function setNamespace($namespace)
63 63
     {
64
-        $namespace = (string) $namespace;
64
+        $namespace = (string)$namespace;
65 65
 
66 66
         if (128 < strlen($namespace)) {
67 67
             throw new Exception\InvalidArgumentException(sprintf(
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function setNamespaceSeparator($namespaceSeparator)
84 84
     {
85
-        $namespaceSeparator = (string) $namespaceSeparator;
85
+        $namespaceSeparator = (string)$namespaceSeparator;
86 86
         if ($this->namespaceSeparator !== $namespaceSeparator) {
87 87
             $this->triggerOptionEvent('namespace_separator', $namespaceSeparator);
88 88
             $this->namespaceSeparator = $namespaceSeparator;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function setResourceId($resourceId)
153 153
     {
154
-        $resourceId = (string) $resourceId;
154
+        $resourceId = (string)$resourceId;
155 155
         if ($this->resourceId !== $resourceId) {
156 156
             $this->triggerOptionEvent('resource_id', $resourceId);
157 157
             $this->resourceId = $resourceId;
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * zf-couchbase2.
4
- *
5
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
11
- * SOFTWARE.
12
- *
13
- * @copyright 2015 MehrAlsNix (http://www.mehralsnix.de)
14
- * @license   http://www.opensource.org/licenses/mit-license.php MIT
15
- *
16
- * @link      http://github.com/MehrAlsNix/zf-couchbase2
17
- */
3
+     * zf-couchbase2.
4
+     *
5
+     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
+     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
+     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
+     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
+     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
+     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
11
+     * SOFTWARE.
12
+     *
13
+     * @copyright 2015 MehrAlsNix (http://www.mehralsnix.de)
14
+     * @license   http://www.opensource.org/licenses/mit-license.php MIT
15
+     *
16
+     * @link      http://github.com/MehrAlsNix/zf-couchbase2
17
+     */
18 18
 namespace MehrAlsNix\ZF\Cache\Storage\Adapter;
19 19
 
20 20
 use CouchbaseBucket as CouchbaseBucketResource;
Please login to merge, or discard this patch.
src/Cache/Storage/Adapter/CouchbaseResourceManager.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * zf-couchbase2.
4
- *
5
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
11
- * SOFTWARE.
12
- *
13
- * @copyright 2015 MehrAlsNix (http://www.mehralsnix.de)
14
- * @license   http://www.opensource.org/licenses/mit-license.php MIT
15
- *
16
- * @link      http://github.com/MehrAlsNix/zf-couchbase2
17
- */
3
+     * zf-couchbase2.
4
+     *
5
+     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
+     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
+     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
+     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
+     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
+     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
11
+     * SOFTWARE.
12
+     *
13
+     * @copyright 2015 MehrAlsNix (http://www.mehralsnix.de)
14
+     * @license   http://www.opensource.org/licenses/mit-license.php MIT
15
+     *
16
+     * @link      http://github.com/MehrAlsNix/zf-couchbase2
17
+     */
18 18
 namespace MehrAlsNix\ZF\Cache\Storage\Adapter;
19 19
 
20 20
 use CouchbaseBucket as CouchbaseBucketResource;
Please login to merge, or discard this patch.
Doc Comments   +11 added lines, -2 removed lines patch added patch discarded remove patch
@@ -309,6 +309,9 @@  discard block
 block discarded – undo
309 309
         return $this;
310 310
     }
311 311
 
312
+    /**
313
+     * @param string $id
314
+     */
312 315
     public function getUsername($id)
313 316
     {
314 317
         if (!$this->hasResource($id)) {
@@ -345,7 +348,7 @@  discard block
 block discarded – undo
345 348
     /**
346 349
      * Get encoder.
347 350
      *
348
-     * @param $id
351
+     * @param string $id
349 352
      *
350 353
      * @return CouchbaseBucketResource
351 354
      */
@@ -385,7 +388,7 @@  discard block
 block discarded – undo
385 388
     /**
386 389
      * Get decoder.
387 390
      *
388
-     * @param $id
391
+     * @param string $id
389 392
      *
390 393
      * @return CouchbaseBucketResource
391 394
      */
@@ -428,6 +431,9 @@  discard block
 block discarded – undo
428 431
         return $this;
429 432
     }
430 433
 
434
+    /**
435
+     * @param string $id
436
+     */
431 437
     public function getBucket($id)
432 438
     {
433 439
         if (!$this->hasResource($id)) {
@@ -467,6 +473,9 @@  discard block
 block discarded – undo
467 473
         return $this;
468 474
     }
469 475
 
476
+    /**
477
+     * @param string $id
478
+     */
470 479
     public function getPassword($id)
471 480
     {
472 481
         if (!$this->hasResource($id)) {
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
         if (is_array($server)) {
77 77
             // array(<host>[, <port>])
78 78
             if (isset($server[0])) {
79
-                $host = (string) $server[0];
80
-                $port = isset($server[1]) ? (int) $server[1] : $port;
79
+                $host = (string)$server[0];
80
+                $port = isset($server[1]) ? (int)$server[1] : $port;
81 81
             }
82 82
             // array('host' => <host>[, 'port' => <port>])
83 83
             if (!isset($server[0]) && isset($server['host'])) {
84
-                $host = (string) $server['host'];
85
-                $port = isset($server['port']) ? (int) $server['port'] : $port;
84
+                $host = (string)$server['host'];
85
+                $port = isset($server['port']) ? (int)$server['port'] : $port;
86 86
             }
87 87
         } else {
88 88
             // parse server from URI host{:?port}
89 89
             $server = trim($server);
90 90
             if (strpos($server, '://') === false) {
91
-                $server = 'couchbase://'.$server;
91
+                $server = 'couchbase://' . $server;
92 92
             }
93 93
             $server = parse_url($server);
94 94
             if (!$server) {
95 95
                 throw new Exception\InvalidArgumentException('Invalid server given');
96 96
             }
97 97
             $host = $server['host'];
98
-            $port = isset($server['port']) ? (int) $server['port'] : $port;
98
+            $port = isset($server['port']) ? (int)$server['port'] : $port;
99 99
             if (isset($server['query'])) {
100 100
                 $query = null;
101 101
                 parse_str($server['query'], $query);
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
         if ($resource instanceof \CouchbaseBucket) {
141 141
             return $resource;
142 142
         }
143
-        $memc = new CouchbaseClusterResource('couchbase://'.$resource['server'][0]['host'].':'.$resource['server'][0]['port'], (string) $resource['username'], (string) $resource['password']);
144
-        $bucket = $memc->openBucket((string) $resource['bucket'], (string) $resource['password']);
143
+        $memc = new CouchbaseClusterResource('couchbase://' . $resource['server'][0]['host'] . ':' . $resource['server'][0]['port'], (string)$resource['username'], (string)$resource['password']);
144
+        $bucket = $memc->openBucket((string)$resource['bucket'], (string)$resource['password']);
145 145
 
146 146
         $bucket->setTranscoder(
147 147
             $resource['encoder'],
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      */
168 168
     public function setResource($id, $resource)
169 169
     {
170
-        $id = (string) $id;
170
+        $id = (string)$id;
171 171
         if (!($resource instanceof CouchbaseBucketResource)) {
172 172
             if ($resource instanceof \Traversable) {
173 173
                 $resource = ArrayUtils::iteratorToArray($resource);
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         $result = [];
496 496
         foreach ($servers as $server) {
497 497
             $this->normalizeServer($server);
498
-            $result[$server['host'].':'.$server['port']] = $server;
498
+            $result[$server['host'] . ':' . $server['port']] = $server;
499 499
         }
500 500
         $servers = array_values($result);
501 501
     }
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
      */
512 512
     protected function compareServers(array $serverA, array $serverB)
513 513
     {
514
-        $keyA = $serverA['host'].':'.$serverA['port'];
515
-        $keyB = $serverB['host'].':'.$serverB['port'];
514
+        $keyA = $serverA['host'] . ':' . $serverA['port'];
515
+        $keyB = $serverB['host'] . ':' . $serverB['port'];
516 516
         if ($keyA === $keyB) {
517 517
             return 0;
518 518
         }
Please login to merge, or discard this patch.