@@ -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 | } |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | $ip = $this->getClientIP(); |
| 426 | 426 | $url = self::GEOCODE_SERVICE_URL.$ip; |
| 427 | 427 | $result = file_get_contents($url); |
| 428 | - switch ($result[0]) { |
|
| 428 | + switch ($result[ 0 ]) { |
|
| 429 | 429 | case '1': |
| 430 | 430 | $data = explode(';', $result); |
| 431 | 431 | |
| 432 | - return $data[1]; |
|
| 432 | + return $data[ 1 ]; |
|
| 433 | 433 | break; |
| 434 | 434 | default: |
| 435 | 435 | return false; |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | { |
| 448 | 448 | $taxKey = 'vat_calculator.rules.'.strtoupper($countryCode); |
| 449 | 449 | |
| 450 | - return isset($this->taxRules[strtoupper($countryCode)]) || (isset($this->config) && $this->config->has($taxKey)); |
|
| 450 | + return isset($this->taxRules[ strtoupper($countryCode) ]) || (isset($this->config) && $this->config->has($taxKey)); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | /** |
@@ -622,24 +622,24 @@ discard block |
||
| 622 | 622 | return $this->config->get($taxKey, 0); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - if (isset($this->postalCodeExceptions[$countryCode]) && $postalCode !== null) { |
|
| 626 | - foreach ($this->postalCodeExceptions[$countryCode] as $postalCodeException) { |
|
| 627 | - if (!preg_match($postalCodeException['postalCode'], $postalCode)) { |
|
| 625 | + if (isset($this->postalCodeExceptions[ $countryCode ]) && $postalCode !== null) { |
|
| 626 | + foreach ($this->postalCodeExceptions[ $countryCode ] as $postalCodeException) { |
|
| 627 | + if (!preg_match($postalCodeException[ 'postalCode' ], $postalCode)) { |
|
| 628 | 628 | continue; |
| 629 | 629 | } |
| 630 | - if (isset($postalCodeException['name'])) { |
|
| 631 | - return $this->taxRules[$postalCodeException['code']]['exceptions'][$postalCodeException['name']]; |
|
| 630 | + if (isset($postalCodeException[ 'name' ])) { |
|
| 631 | + return $this->taxRules[ $postalCodeException[ 'code' ] ][ 'exceptions' ][ $postalCodeException[ 'name' ] ]; |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - return $this->taxRules[$postalCodeException['code']]['rate']; |
|
| 634 | + return $this->taxRules[ $postalCodeException[ 'code' ] ][ 'rate' ]; |
|
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | if ($type !== null) { |
| 639 | - return isset($this->taxRules[strtoupper($countryCode)]['rates'][$type]) ? $this->taxRules[strtoupper($countryCode)]['rates'][$type] : 0; |
|
| 639 | + return isset($this->taxRules[ strtoupper($countryCode) ][ 'rates' ][ $type ]) ? $this->taxRules[ strtoupper($countryCode) ][ 'rates' ][ $type ] : 0; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - return isset($this->taxRules[strtoupper($countryCode)]['rate']) ? $this->taxRules[strtoupper($countryCode)]['rate'] : 0; |
|
| 642 | + return isset($this->taxRules[ strtoupper($countryCode) ][ 'rate' ]) ? $this->taxRules[ strtoupper($countryCode) ][ 'rate' ] : 0; |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | */ |
| 678 | 678 | public function getVATDetails($vatNumber) |
| 679 | 679 | { |
| 680 | - $vatNumber = str_replace([' ', "\xC2\xA0", "\xA0", '-', '.', ','], '', trim($vatNumber)); |
|
| 680 | + $vatNumber = str_replace([ ' ', "\xC2\xA0", "\xA0", '-', '.', ',' ], '', trim($vatNumber)); |
|
| 681 | 681 | $countryCode = substr($vatNumber, 0, 2); |
| 682 | 682 | $vatNumber = substr($vatNumber, 2); |
| 683 | 683 | $this->initSoapClient(); |