Completed
Push — master ( bb42d5...3141b5 )
by Adam
01:00
created
src/IPub/FormPhone/Controls/Phone.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * Define filed attributes
46 46
 	 */
47
-	const FIELD_COUNTRY	= 'country';
48
-	const FIELD_NUMBER	= 'number';
47
+	const FIELD_COUNTRY = 'country';
48
+	const FIELD_NUMBER = 'number';
49 49
 
50 50
 	/**
51 51
 	 * @var IPub\Phone\Phone
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			}
262 262
 		}
263 263
 
264
-		throw new Exceptions\InvalidArgumentException('Provided value is not valid phone number, or is out of list of allowed countries, "' . $value . '" given.');
264
+		throw new Exceptions\InvalidArgumentException('Provided value is not valid phone number, or is out of list of allowed countries, "'.$value.'" given.');
265 265
 	}
266 266
 
267 267
 	/**
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	public function loadHttpData()
296 296
 	{
297
-		$country = $this->getHttpData(Forms\Form::DATA_LINE, '[' . static::FIELD_COUNTRY . ']');
297
+		$country = $this->getHttpData(Forms\Form::DATA_LINE, '['.static::FIELD_COUNTRY.']');
298 298
 		$this->country = ($country === '' || $country === NULL) ? NULL : (string) $country;
299 299
 
300
-		$number = $this->getHttpData(Forms\Form::DATA_LINE, '[' . static::FIELD_NUMBER . ']');
300
+		$number = $this->getHttpData(Forms\Form::DATA_LINE, '['.static::FIELD_NUMBER.']');
301 301
 		$this->number = ($number === '' || $number === NULL) ? NULL : (string) $number;
302 302
 	}
303 303
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	public function getControl()
308 308
 	{
309 309
 		return Utils\Html::el()
310
-			->add($this->getControlPart(static::FIELD_COUNTRY) . $this->getControlPart(static::FIELD_NUMBER));
310
+			->add($this->getControlPart(static::FIELD_COUNTRY).$this->getControlPart(static::FIELD_NUMBER));
311 311
 	}
312 312
 
313 313
 	/**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 					);
346 346
 
347 347
 					$result[$row] = Utils\Html::el('option')
348
-						->setText('+' . $this->phoneUtils->getCountryCodeForCountry($row) . ' (' . $countryName . ')')
348
+						->setText('+'.$this->phoneUtils->getCountryCodeForCountry($row).' ('.$countryName.')')
349 349
 						->addAttributes([
350 350
 							'data-mask' => preg_replace('/[0-9]/', '9', $this->phoneUtils->getExampleNationalNumber($row)),
351 351
 						])
@@ -359,12 +359,12 @@  discard block
 block discarded – undo
359 359
 			);
360 360
 
361 361
 			$control->addAttributes([
362
-				'name' => $name . '[' . static::FIELD_COUNTRY . ']',
363
-				'id'   => $this->getHtmlId() . '-' . static::FIELD_COUNTRY,
362
+				'name' => $name.'['.static::FIELD_COUNTRY.']',
363
+				'id'   => $this->getHtmlId().'-'.static::FIELD_COUNTRY,
364 364
 
365 365
 				'data-ipub-forms-phone' => '',
366 366
 				'data-settings'         => json_encode([
367
-					'field' => $name . '[' . static::FIELD_NUMBER . ']'
367
+					'field' => $name.'['.static::FIELD_NUMBER.']'
368 368
 				])
369 369
 			]);
370 370
 
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 			$control = Utils\Html::el('input');
381 381
 
382 382
 			$control->addAttributes([
383
-				'name'  => $name . '[' . static::FIELD_NUMBER . ']',
384
-				'id'    => $this->getHtmlId() . '-' . static::FIELD_NUMBER,
383
+				'name'  => $name.'['.static::FIELD_NUMBER.']',
384
+				'id'    => $this->getHtmlId().'-'.static::FIELD_NUMBER,
385 385
 				'value' => $this->number,
386 386
 				'type'  => 'text',
387 387
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 			return $control;
397 397
 		}
398 398
 
399
-		throw new Exceptions\InvalidArgumentException('Part ' . $key . ' does not exist.');
399
+		throw new Exceptions\InvalidArgumentException('Part '.$key.' does not exist.');
400 400
 	}
401 401
 
402 402
 	/**
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 			return $country;
424 424
 
425 425
 		} else {
426
-			throw new Exceptions\NoValidCountryException('Provided country code "' . $country . '" is not valid. Provide valid country code or AUTO for automatic detection.');
426
+			throw new Exceptions\NoValidCountryException('Provided country code "'.$country.'" is not valid. Provide valid country code or AUTO for automatic detection.');
427 427
 		}
428 428
 	}
429 429
 
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
 		// Phone type have to be upper-cased
440 440
 		$type = strtoupper($type);
441 441
 
442
-		if (defined('\IPub\Phone\Phone::TYPE_' . $type)) {
442
+		if (defined('\IPub\Phone\Phone::TYPE_'.$type)) {
443 443
 			return $type;
444 444
 
445 445
 		} else {
446
-			throw new Exceptions\NoValidTypeException('Provided phone type "' . $type . '" is not valid. Provide valid phone type.');
446
+			throw new Exceptions\NoValidTypeException('Provided phone type "'.$type.'" is not valid. Provide valid phone type.');
447 447
 		}
448 448
 	}
449 449
 
Please login to merge, or discard this patch.
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -18,15 +18,11 @@
 block discarded – undo
18 18
 use Nette\Forms;
19 19
 use Nette\Localization;
20 20
 use Nette\Utils;
21
-
22 21
 use IPub;
23 22
 use IPub\FormPhone;
24 23
 use IPub\FormPhone\Exceptions;
25
-
26 24
 use IPub\Phone\Phone as PhoneUtils;
27 25
 
28
-use libphonenumber;
29
-
30 26
 /**
31 27
  * Form phone control element
32 28
  *
Please login to merge, or discard this patch.
src/IPub/FormPhone/Forms/PhoneValidator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 	public static function validatePhone(Forms\IControl $control, $params = [])
58 58
 	{
59 59
 		if (!$control instanceof Controls\Phone) {
60
-			throw new Exceptions\InvalidArgumentException('This validator could be used only on text field. You used it on: "' . get_class($control) . '"');
60
+			throw new Exceptions\InvalidArgumentException('This validator could be used only on text field. You used it on: "'.get_class($control).'"');
61 61
 		}
62 62
 
63 63
 		// Get form element value
Please login to merge, or discard this patch.
src/IPub/FormPhone/Locale/Locale.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
15 15
 	 */
16 16
 	public static function countryCodeToLocale($countryCode, $languageCode = '')
17 17
 	{
18
-		$locale = 'en-' . $countryCode;
18
+		$locale = 'en-'.$countryCode;
19 19
 		$localeRegion = locale_get_region($locale);
20 20
 		$localeLanguage = locale_get_primary_language($locale);
21
-		$localeArray= [
21
+		$localeArray = [
22 22
 			'language' => $localeLanguage,
23 23
 			'region' => $localeRegion,
24 24
 		];
Please login to merge, or discard this patch.