PluginProbe
Packeta / 2.3.2
Packeta v2.3.2
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
← All changes | src/Packetery/Core/Rounder.php +11 -8 1.5.3 → 2.3.2 View file →
@@ -121,13 +121,13 @@
121 121 )
122 122 );
123 123 }
124 124
125 - if ( 'CZK' === $currencyCode ) {
125 + if ( $currencyCode === 'CZK' ) {
126 126 return self::round( $amount, $roundingType, 0 );
127 127 }
128 128
129 - if ( 'HUF' === $currencyCode ) {
129 + if ( $currencyCode === 'HUF' ) {
130 130 return self::roundToMultipleOfNumber( $amount, $roundingType, 5 );
131 131 }
132 132
133 133 return self::round( $amount, $roundingType, 2 );
@@ -141,12 +141,12 @@
141 141 *
142 142 * @return float
143 143 */
144 144 private static function roundFloat( float $amount, int $roundingType ): float {
145 - if ( self::ROUND_DOWN === $roundingType ) {
145 + if ( $roundingType === self::ROUND_DOWN ) {
146 146 return floor( self::sanitizeFloat( $amount ) );
147 147 }
148 - if ( self::ROUND_UP === $roundingType ) {
148 + if ( $roundingType === self::ROUND_UP ) {
149 149 return ceil( self::sanitizeFloat( $amount ) );
150 150 }
151 151
152 152 return $amount;
@@ -160,13 +160,16 @@
160 160 *
161 161 * @return float
162 162 */
163 163 private static function sanitizeFloat( float $number ): float {
164 - $oldLocale = setlocale( LC_NUMERIC, 0 );
165 - setlocale( LC_NUMERIC, 'C' );
164 + $oldLocale = setlocale( LC_NUMERIC, '0' );
165 + if ( $oldLocale !== false ) {
166 + setlocale( LC_NUMERIC, 'C' );
167 + }
166 168 $newNumber = (float) ( (string) $number );
167 - setlocale( LC_NUMERIC, $oldLocale );
169 + if ( $oldLocale !== false ) {
170 + setlocale( LC_NUMERIC, $oldLocale );
171 + }
168 172
169 173 return $newNumber;
170 174 }
171 -
172 175 }