Passed
Pull Request — master (#137)
by Jordan
06:22
created
Samsara/Fermat/Provider/RoundingModeAdapters/Modes/StochasticAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
             $remainder = substr($remainder, 0, 3);
27 27
             $target = (int)($digit.$remainder);
28 28
             $rangeMin = 0;
29
-            $rangeMax = (int)str_repeat('9', strlen($remainder) + 1);
29
+            $rangeMax = (int)str_repeat('9', strlen($remainder)+1);
30 30
         }
31 31
 
32 32
         $random = RandomProvider::randomInt($rangeMin, $rangeMax, RandomMode::Speed)->asInt();
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/RoundingModeAdapters/Modes/HalfOddAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
         $remainder = $this->remainderCheck();
18 18
 
19 19
         if ($early == 0) {
20
-            return ($nextDigit % 2 == 1 && !$remainder) ? 0 : 1;
20
+            return ($nextDigit%2 == 1 && !$remainder) ? 0 : 1;
21 21
         } else {
22 22
             return $early == 1 ? 1 : 0;
23 23
         }
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/RoundingModeAdapters/Modes/HalfEvenAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
         $remainder = $this->remainderCheck();
18 18
 
19 19
         if ($early == 0) {
20
-            return ($nextDigit % 2 == 0 && !$remainder) ? 0 : 1;
20
+            return ($nextDigit%2 == 0 && !$remainder) ? 0 : 1;
21 21
         } else {
22 22
             return $early == 1 ? 1 : 0;
23 23
         }
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/RandomProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
      * @throws IncompatibleObjectState
31 31
      */
32 32
     public static function randomInt(
33
-        int|string|DecimalInterface $min,
34
-        int|string|DecimalInterface $max,
33
+        int | string | DecimalInterface $min,
34
+        int | string | DecimalInterface $max,
35 35
         RandomMode $mode = RandomMode::Entropy
36 36
     ): ImmutableDecimal
37 37
     {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     throw new OptionalExit(
108 108
                         'System error from random_bytes().',
109 109
                         'Ensure your system is configured correctly.',
110
-                        'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: ' . $e->getMessage()
110
+                        'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: '.$e->getMessage()
111 111
                     );
112 112
                 }
113 113
             } elseif ($mode == RandomMode::Speed) {
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
                      */
148 148
                     $entropyBytes = random_bytes($bytesNeeded->asInt());
149 149
                     $baseTwoBytes = '';
150
-                    for($i = 0; $i < strlen($entropyBytes); $i++){
151
-                        $baseTwoBytes .= decbin( ord( $entropyBytes[$i] ) );
150
+                    for ($i = 0;$i < strlen($entropyBytes);$i++) {
151
+                        $baseTwoBytes .= decbin(ord($entropyBytes[$i]));
152 152
                     }
153 153
                 } catch (Exception $e) {
154 154
                     throw new OptionalExit(
155 155
                         'System error from random_bytes().',
156 156
                         'Ensure your system is configured correctly.',
157
-                        'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: ' . $e->getMessage()
157
+                        'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: '.$e->getMessage()
158 158
                     );
159 159
                 }
160 160
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
      * @throws IncompatibleObjectState
244 244
      */
245 245
     public static function randomReal(
246
-        int|string|DecimalInterface $min,
247
-        int|string|DecimalInterface $max,
246
+        int | string | DecimalInterface $min,
247
+        int | string | DecimalInterface $max,
248 248
         int $scale,
249 249
         RandomMode $mode = RandomMode::Entropy
250 250
     ): ImmutableDecimal
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
                  * We cannot take advantage of a more efficient check for the top end of the range, so the
370 370
                  * less than check is all we need.
371 371
                  */
372
-                $maxDecimal = str_pad('1', $scale + 1, '0');
372
+                $maxDecimal = str_pad('1', $scale+1, '0');
373 373
             } else {
374 374
                 /**
375 375
                  * The max value is guaranteed to have a decimal portion here since we excluded max being
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/RoundingProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             $roundedPartString = $wholePart;
141 141
             $otherPart = str_split($decimalPart);
142 142
             $baseLength = strlen($wholePart);
143
-            $pos = ($absPlaces >= $baseLength) ? 0 : $baseLength + $places;
143
+            $pos = ($absPlaces >= $baseLength) ? 0 : $baseLength+$places;
144 144
         }
145 145
 
146 146
         return [
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         bool $currentPart
215 215
     ): array
216 216
     {
217
-        $digit = (int)$roundedPart[$pos] + $carry;
217
+        $digit = (int)$roundedPart[$pos]+$carry;
218 218
 
219 219
         if ($carry == 0 && $digit == 5 && strlen($roundedPartString) > $pos+1) {
220 220
             $remainder = substr($roundedPartString, $pos+1);
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/NumberFormatProvider.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             $number = str_replace('-', '-'.$currency->value, $number);
34 34
             $number = str_replace('+', '+'.$currency->value, $number);
35 35
         } else {
36
-            $number = $currency->value . $number;
36
+            $number = $currency->value.$number;
37 37
         }
38 38
 
39 39
         return $number;
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
             $number = $wholePart;
72 72
 
73 73
             if ($decimalPart) {
74
-                $number .= self::getRadixCharacter($format) . $decimalPart;
74
+                $number .= self::getRadixCharacter($format).$decimalPart;
75 75
             }
76 76
         }
77 77
 
78 78
         if (str_contains($posNegChar, '\N')) {
79 79
             $number = str_replace('\N', $number, $posNegChar);
80 80
         } else {
81
-            $number = $posNegChar . $number;
81
+            $number = $posNegChar.$number;
82 82
         }
83 83
 
84 84
         return $number;
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
         if ($wholeSizeNonZero) {
108 108
             $exponent = $wholeSizeNonZero;
109 109
             $exponent -= 1;
110
-            $mantissa = substr($wholePart, 0, 1) . '.' . substr($wholePart, 1) . $decimalPart;
110
+            $mantissa = substr($wholePart, 0, 1).'.'.substr($wholePart, 1).$decimalPart;
111 111
         } else {
112
-            $exponent = strlen($decimalPart) - $decimalSizeNonZero;
112
+            $exponent = strlen($decimalPart)-$decimalSizeNonZero;
113 113
             $exponent += 1;
114
-            $mantissa = substr($decimalPart, $exponent-1, 1) . '.' . substr($decimalPart, $exponent);
114
+            $mantissa = substr($decimalPart, $exponent-1, 1).'.'.substr($decimalPart, $exponent);
115 115
             $exponent *= -1;
116 116
         }
117 117
 
118 118
         $mantissa = rtrim($mantissa, '0');
119 119
 
120
-        return $negative . $mantissa . 'E' . $exponent . $imaginary;
120
+        return $negative.$mantissa.'E'.$exponent.$imaginary;
121 121
     }
122 122
 
123 123
     /**
@@ -137,18 +137,18 @@  discard block
 block discarded – undo
137 137
         $formatted = '';
138 138
 
139 139
         for ($i = 0;$i < count($numberArr);$i++) {
140
-            $j = $i + 1;
140
+            $j = $i+1;
141 141
 
142 142
             $formatted = $numberArr[$i].$formatted;
143 143
 
144 144
             if ($grouping == NumberGrouping::Standard) {
145
-                if ($j % 3 == 0 && array_key_exists($i+1, $numberArr)) {
145
+                if ($j%3 == 0 && array_key_exists($i+1, $numberArr)) {
146 146
                     $formatted = self::getDelimiterCharacter($format).$formatted;
147 147
                 }
148 148
             } elseif ($grouping == NumberGrouping::Indian) {
149 149
                 if ($j == 3 && array_key_exists($i+1, $numberArr)) {
150 150
                     $formatted = self::getDelimiterCharacter($format).$formatted;
151
-                } elseif (($j - 3) % 2 == 0 && ($j - 3) > 0 && array_key_exists($i+1, $numberArr)) {
151
+                } elseif (($j-3)%2 == 0 && ($j-3) > 0 && array_key_exists($i+1, $numberArr)) {
152 152
                     $formatted = self::getDelimiterCharacter($format).$formatted;
153 153
                 }
154 154
             }
Please login to merge, or discard this patch.