@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * @param mixed $countryCode |
|
| 191 | + * @param string $countryCode |
|
| 192 | 192 | */ |
| 193 | 193 | public function setCountryCode($countryCode) |
| 194 | 194 | { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * @param $vatNumber |
|
| 252 | + * @param string $vatNumber |
|
| 253 | 253 | * |
| 254 | 254 | * @throws VATCheckUnavailableException |
| 255 | 255 | * |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | private function getClientIP() |
| 129 | 129 | { |
| 130 | - if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) { |
|
| 131 | - $clientIpAddress = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 132 | - } elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR']) { |
|
| 133 | - $clientIpAddress = $_SERVER['REMOTE_ADDR']; |
|
| 130 | + if (isset($_SERVER[ 'HTTP_X_FORWARDED_FOR' ]) && $_SERVER[ 'HTTP_X_FORWARDED_FOR' ]) { |
|
| 131 | + $clientIpAddress = $_SERVER[ 'HTTP_X_FORWARDED_FOR' ]; |
|
| 132 | + } elseif (isset($_SERVER[ 'REMOTE_ADDR' ]) && $_SERVER[ 'REMOTE_ADDR' ]) { |
|
| 133 | + $clientIpAddress = $_SERVER[ 'REMOTE_ADDR' ]; |
|
| 134 | 134 | } else { |
| 135 | 135 | $clientIpAddress = ''; |
| 136 | 136 | } |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | $ip = $this->getClientIP(); |
| 151 | 151 | $url = self::GEOCODE_SERVICE_URL.$ip; |
| 152 | 152 | $result = file_get_contents($url); |
| 153 | - switch ($result[0]) { |
|
| 153 | + switch ($result[ 0 ]) { |
|
| 154 | 154 | case '1': |
| 155 | 155 | $data = explode(';', $result); |
| 156 | 156 | |
| 157 | - return $data[1]; |
|
| 157 | + return $data[ 1 ]; |
|
| 158 | 158 | break; |
| 159 | 159 | default: |
| 160 | 160 | return false; |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | $taxKey = 'vat_calculator.rules.'.strtoupper($countryCode); |
| 174 | 174 | |
| 175 | - return isset($this->taxRules[strtoupper($countryCode)]) || (isset($this->config) && $this->config->has($taxKey)); |
|
| 175 | + return isset($this->taxRules[ strtoupper($countryCode) ]) || (isset($this->config) && $this->config->has($taxKey)); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | return $this->config->get($taxKey, 0); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - return isset($this->taxRules[strtoupper($countryCode)]) ? $this->taxRules[strtoupper($countryCode)] : 0; |
|
| 278 | + return isset($this->taxRules[ strtoupper($countryCode) ]) ? $this->taxRules[ strtoupper($countryCode) ] : 0; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | public function isValidVATNumber($vatNumber) |
| 297 | 297 | { |
| 298 | - $vatNumber = str_replace([' ', '-', '.', ','], '', trim($vatNumber)); |
|
| 298 | + $vatNumber = str_replace([ ' ', '-', '.', ',' ], '', trim($vatNumber)); |
|
| 299 | 299 | $countryCode = substr($vatNumber, 0, 2); |
| 300 | 300 | $vatNumber = substr($vatNumber, 2); |
| 301 | 301 | |
@@ -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 | use Mpociot\VatCalculator\Validators\VatCalculatorValidatorExtension; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $this->app->bind('vatcalculator', '\Mpociot\VatCalculator\VatCalculator'); |
| 74 | 74 | |
| 75 | - $this->app->bind('\Mpociot\VatCalculator\VatCalculator', function ($app) { |
|
| 75 | + $this->app->bind('\Mpociot\VatCalculator\VatCalculator', function($app) { |
|
| 76 | 76 | $config = $app->make('Illuminate\Contracts\Config\Repository'); |
| 77 | 77 | |
| 78 | 78 | return new \Mpociot\VatCalculator\VatCalculator($config); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function registerFacade() |
| 88 | 88 | { |
| 89 | - $this->app->booting(function () { |
|
| 89 | + $this->app->booting(function() { |
|
| 90 | 90 | $loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
| 91 | 91 | $loader->alias('VatCalculator', 'Mpociot\VatCalculator\Facades\VatCalculator'); |
| 92 | 92 | }); |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | 114 | // Registering the validator extension with the validator factory |
| 115 | - $this->app['validator']->resolver( |
|
| 116 | - function ($translator, $data, $rules, $messages, $customAttributes = []) { |
|
| 115 | + $this->app[ 'validator' ]->resolver( |
|
| 116 | + function($translator, $data, $rules, $messages, $customAttributes = [ ]) { |
|
| 117 | 117 | return new VatCalculatorValidatorExtension( |
| 118 | 118 | $translator, |
| 119 | 119 | $data, |
@@ -11,11 +11,11 @@ |
||
| 11 | 11 | /** |
| 12 | 12 | * Creates a new instance of ValidatorExtension. |
| 13 | 13 | */ |
| 14 | - public function __construct($translator, $data, $rules, $messages, array $customAttributes = []) |
|
| 14 | + public function __construct($translator, $data, $rules, $messages, array $customAttributes = [ ]) |
|
| 15 | 15 | { |
| 16 | 16 | // Set custom validation error messages |
| 17 | - if (!isset($messages['vat_number'])) { |
|
| 18 | - $messages['vat_number'] = $translator->get( |
|
| 17 | + if (!isset($messages[ 'vat_number' ])) { |
|
| 18 | + $messages[ 'vat_number' ] = $translator->get( |
|
| 19 | 19 | 'vatnumber-validator::validation.vat_number' |
| 20 | 20 | ); |
| 21 | 21 | } |
@@ -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 | |