Completed
Branch master (9ba1aa)
by Prasetyo
04:34
created
src/Feature/Config.php 2 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -190,6 +190,11 @@  discard block
 block discarded – undo
190 190
      * variantFor, in which case we want to perform some certain
191 191
      * sanity checks to make sure the code is being used correctly.
192 192
      */
193
+
194
+    /**
195
+     * @param integer $userId
196
+     * @param boolean $inVariantMethod
197
+     */
193 198
     private function chooseVariant($bucketingId, $userId, $inVariantMethod)
194 199
     {
195 200
         if ($inVariantMethod && $this->enabled === self::ON) {
@@ -362,6 +367,10 @@  discard block
 block discarded – undo
362 367
      * should see each variant to map a randomish number to a
363 368
      * particular variant.
364 369
      */
370
+
371
+    /**
372
+     * @param string $id
373
+     */
365 374
     private function variantByPercentage($id)
366 375
     {
367 376
         $n = 100 * $this->randomish($id);
@@ -447,6 +456,10 @@  discard block
 block discarded – undo
447 456
      * feature's config stanza, returning an array mappinng the user
448 457
      * or group names to they variant they should see.
449 458
      */
459
+
460
+    /**
461
+     * @param string $what
462
+     */
450 463
     private function parseUsersOrGroups($stanza, $what)
451 464
     {
452 465
         $value = Util::arrayGet($stanza, $what);
@@ -487,6 +500,10 @@  discard block
 block discarded – undo
487 500
      * properties. If non-falsy, must be one of the keys in the
488 501
      * enabled map unless enabled is 'on' or 'off'.
489 502
      */
503
+
504
+    /**
505
+     * @param string $what
506
+     */
490 507
     private function parseVariantName($stanza, $what)
491 508
     {
492 509
         $value = Util::arrayGet($stanza, $what);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     const BUCKETING           = 'bucketing';
23 23
 
24 24
     /* Special values for enabled property. */
25
-    const ON  = 'on';  /* Feature is fully enabled. */
25
+    const ON  = 'on'; /* Feature is fully enabled. */
26 26
     const OFF = 'off'; /* Feature is fully disabled. */
27 27
 
28 28
     /* Bucketing schemes. */
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                 );
210 210
             }
211 211
 
212
-            $bucketingId = (string)$bucketingId;
212
+            $bucketingId = (string) $bucketingId;
213 213
             if (array_key_exists($bucketingId, $this->cache)) {
214 214
                 // Note that this caching is not just an optimization:
215 215
                 // it prevents us from double logging a single
@@ -223,13 +223,7 @@  discard block
 block discarded – undo
223 223
                 return $this->cache[$bucketingId];
224 224
             } else {
225 225
                 list($v, $selector) =
226
-                    $this->variantFromURL($userId) ?:
227
-                        $this->variantForUser($userId) ?:
228
-                            $this->variantForGroup($userId) ?:
229
-                                $this->variantForAdmin($userId) ?:
230
-                                    $this->variantForInternal() ?:
231
-                                        $this->variantByPercentage($bucketingId) ?:
232
-                                            array(self::OFF, 'w');
226
+                    $this->variantFromURL($userId) ?: $this->variantForUser($userId) ?: $this->variantForGroup($userId) ?: $this->variantForAdmin($userId) ?: $this->variantForInternal() ?: $this->variantByPercentage($bucketingId) ?: array(self::OFF, 'w');
233 227
 
234 228
                 if ($inVariantMethod && $v === self::OFF) {
235 229
                     $this->error("Variant check outside enabled check");
@@ -465,8 +459,7 @@  discard block
 block discarded – undo
465 459
         } elseif (is_array($value)) {
466 460
             $result = array();
467 461
             $bad_keys = is_array($this->enabled) ?
468
-                array_keys(array_diff_key($value, $this->enabled)) :
469
-                array();
462
+                array_keys(array_diff_key($value, $this->enabled)) : array();
470 463
             if (!$bad_keys) {
471 464
                 foreach ($value as $variant => $whos) {
472 465
                     foreach (self::asArray($whos) as $who) {
Please login to merge, or discard this patch.
src/Feature/Util.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 class Util
11 11
 {
12 12
     /**
13
-     * @return float
13
+     * @return integer
14 14
      */
15 15
     public static function random()
16 16
     {
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
     }
19 19
 
20 20
     /**
21
-     * @param $id
22
-     * @return float
21
+     * @param string $id
22
+     * @return integer
23 23
      */
24 24
     public static function randomById($id)
25 25
     {
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     /**
41 41
      * @param string $hex
42
-     * @return float
42
+     * @return integer
43 43
      */
44 44
     private static function mapHex($hex)
45 45
     {
Please login to merge, or discard this patch.