@@ -402,10 +402,10 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | private function getClientIP() |
| 404 | 404 | { |
| 405 | - if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) { |
|
| 406 | - $clientIpAddress = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 407 | - } elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR']) { |
|
| 408 | - $clientIpAddress = $_SERVER['REMOTE_ADDR']; |
|
| 405 | + if (isset($_SERVER[ 'HTTP_X_FORWARDED_FOR' ]) && $_SERVER[ 'HTTP_X_FORWARDED_FOR' ]) { |
|
| 406 | + $clientIpAddress = $_SERVER[ 'HTTP_X_FORWARDED_FOR' ]; |
|
| 407 | + } elseif (isset($_SERVER[ 'REMOTE_ADDR' ]) && $_SERVER[ 'REMOTE_ADDR' ]) { |
|
| 408 | + $clientIpAddress = $_SERVER[ 'REMOTE_ADDR' ]; |
|
| 409 | 409 | } else { |
| 410 | 410 | $clientIpAddress = ''; |
| 411 | 411 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | public function getIPBasedCountry() |
| 424 | 424 | { |
| 425 | - if (! $ip = $this->getClientIP()) { |
|
| 425 | + if (!$ip = $this->getClientIP()) { |
|
| 426 | 426 | return false; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | { |
| 450 | 450 | $taxKey = 'vat_calculator.rules.'.strtoupper($countryCode); |
| 451 | 451 | |
| 452 | - return isset($this->taxRules[strtoupper($countryCode)]) || (isset($this->config) && $this->config->has($taxKey)); |
|
| 452 | + return isset($this->taxRules[ strtoupper($countryCode) ]) || (isset($this->config) && $this->config->has($taxKey)); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -624,26 +624,26 @@ discard block |
||
| 624 | 624 | return $this->config->get($taxKey, 0); |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - if (isset($this->postalCodeExceptions[$countryCode]) && $postalCode !== null) { |
|
| 628 | - foreach ($this->postalCodeExceptions[$countryCode] as $postalCodeException) { |
|
| 629 | - if (!preg_match($postalCodeException['postalCode'], $postalCode)) { |
|
| 627 | + if (isset($this->postalCodeExceptions[ $countryCode ]) && $postalCode !== null) { |
|
| 628 | + foreach ($this->postalCodeExceptions[ $countryCode ] as $postalCodeException) { |
|
| 629 | + if (!preg_match($postalCodeException[ 'postalCode' ], $postalCode)) { |
|
| 630 | 630 | continue; |
| 631 | 631 | } |
| 632 | - if (isset($postalCodeException['name'])) { |
|
| 633 | - return $this->taxRules[$postalCodeException['code']]['exceptions'][$postalCodeException['name']]; |
|
| 632 | + if (isset($postalCodeException[ 'name' ])) { |
|
| 633 | + return $this->taxRules[ $postalCodeException[ 'code' ] ][ 'exceptions' ][ $postalCodeException[ 'name' ] ]; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - return $this->taxRules[$postalCodeException['code']]['rate']; |
|
| 636 | + return $this->taxRules[ $postalCodeException[ 'code' ] ][ 'rate' ]; |
|
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | if ($type !== null) { |
| 641 | - if (isset($this->taxRules[strtoupper($countryCode)]['rates'][$type])) { |
|
| 642 | - return $this->taxRules[strtoupper($countryCode)]['rates'][$type]; |
|
| 641 | + if (isset($this->taxRules[ strtoupper($countryCode) ][ 'rates' ][ $type ])) { |
|
| 642 | + return $this->taxRules[ strtoupper($countryCode) ][ 'rates' ][ $type ]; |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - return isset($this->taxRules[strtoupper($countryCode)]['rate']) ? $this->taxRules[strtoupper($countryCode)]['rate'] : 0; |
|
| 646 | + return isset($this->taxRules[ strtoupper($countryCode) ][ 'rate' ]) ? $this->taxRules[ strtoupper($countryCode) ][ 'rate' ] : 0; |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /** |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | */ |
| 682 | 682 | public function getVATDetails($vatNumber) |
| 683 | 683 | { |
| 684 | - $vatNumber = str_replace([' ', "\xC2\xA0", "\xA0", '-', '.', ','], '', trim($vatNumber)); |
|
| 684 | + $vatNumber = str_replace([ ' ', "\xC2\xA0", "\xA0", '-', '.', ',' ], '', trim($vatNumber)); |
|
| 685 | 685 | $countryCode = substr($vatNumber, 0, 2); |
| 686 | 686 | $vatNumber = substr($vatNumber, 2); |
| 687 | 687 | $this->initSoapClient(); |