@@ -51,7 +51,7 @@ |
||
| 51 | 51 | $valid_company = false; |
| 52 | 52 | if ($request->has('vat_number')) { |
| 53 | 53 | $valid_company = $this->validateVATID($request->get('vat_number')); |
| 54 | - $valid_company = $valid_company['is_valid']; |
|
| 54 | + $valid_company = $valid_company[ 'is_valid' ]; |
|
| 55 | 55 | $valid_vat_id = $valid_company; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Mpociot\VatCalculator\Validators; |
| 4 | 4 | |
| 5 | -use Illuminate\Validation\Validator; |
|
| 6 | 5 | use Mpociot\VatCalculator\Exceptions\VATCheckUnavailableException; |
| 7 | 6 | use Mpociot\VatCalculator\Facades\VatCalculator; |
| 8 | 7 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
| 457 | - * @param mixed $countryCode |
|
| 457 | + * @param string $countryCode |
|
| 458 | 458 | */ |
| 459 | 459 | public function setCountryCode($countryCode) |
| 460 | 460 | { |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
| 473 | - * @param mixed $postalCode |
|
| 473 | + * @param string $postalCode |
|
| 474 | 474 | */ |
| 475 | 475 | public function setPostalCode($postalCode) |
| 476 | 476 | { |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
| 574 | - * @param $vatNumber |
|
| 574 | + * @param string $vatNumber |
|
| 575 | 575 | * |
| 576 | 576 | * @throws VATCheckUnavailableException |
| 577 | 577 | * |
@@ -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,24 +624,24 @@ 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 | - return isset($this->taxRules[strtoupper($countryCode)]['rates'][$type]) ? $this->taxRules[strtoupper($countryCode)]['rates'][$type] : 0; |
|
| 641 | + return isset($this->taxRules[ strtoupper($countryCode) ][ 'rates' ][ $type ]) ? $this->taxRules[ strtoupper($countryCode) ][ 'rates' ][ $type ] : 0; |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - return isset($this->taxRules[strtoupper($countryCode)]['rate']) ? $this->taxRules[strtoupper($countryCode)]['rate'] : 0; |
|
| 644 | + return isset($this->taxRules[ strtoupper($countryCode) ][ 'rate' ]) ? $this->taxRules[ strtoupper($countryCode) ][ 'rate' ] : 0; |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | */ |
| 680 | 680 | public function getVATDetails($vatNumber) |
| 681 | 681 | { |
| 682 | - $vatNumber = str_replace([' ', "\xC2\xA0", "\xA0", '-', '.', ','], '', trim($vatNumber)); |
|
| 682 | + $vatNumber = str_replace([ ' ', "\xC2\xA0", "\xA0", '-', '.', ',' ], '', trim($vatNumber)); |
|
| 683 | 683 | $countryCode = substr($vatNumber, 0, 2); |
| 684 | 684 | $vatNumber = substr($vatNumber, 2); |
| 685 | 685 | $this->initSoapClient(); |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | * @package Teamwork |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -use Illuminate\Support\Facades\Validator; |
|
| 13 | 12 | use Illuminate\Support\ServiceProvider; |
| 14 | 13 | use Mpociot\VatCalculator\Facades\VatCalculator; |
| 15 | 14 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $this->app->bind('vatcalculator', \Mpociot\VatCalculator\VatCalculator::class); |
| 73 | 73 | |
| 74 | - $this->app->bind(\Mpociot\VatCalculator\VatCalculator::class, function ($app) { |
|
| 74 | + $this->app->bind(\Mpociot\VatCalculator\VatCalculator::class, function($app) { |
|
| 75 | 75 | $config = $app->make('Illuminate\Contracts\Config\Repository'); |
| 76 | 76 | |
| 77 | 77 | return new \Mpociot\VatCalculator\VatCalculator($config); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function registerFacade() |
| 87 | 87 | { |
| 88 | - $this->app->booting(function () { |
|
| 88 | + $this->app->booting(function() { |
|
| 89 | 89 | $loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
| 90 | 90 | $loader->alias('VatCalculator', 'Mpociot\VatCalculator\Facades\VatCalculator'); |
| 91 | 91 | }); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | 'vatnumber-validator' |
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | - $this->app['validator']->extend('vat_number', |
|
| 113 | + $this->app[ 'validator' ]->extend('vat_number', |
|
| 114 | 114 | 'Mpociot\VatCalculator\Validators\VatCalculatorValidatorExtension@validateVatNumber'); |
| 115 | 115 | } |
| 116 | 116 | |