Completed
Push — master ( e6649e...8a7d45 )
by Agel_Nash
02:19
created
src/utils.functions.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 			list(, $domain) = explode("@", $email, 2);
18 18
 			if (!$dns || ($dns && checkdnsrr($domain, "MX") && checkdnsrr($domain, "A"))) {
19 19
 				$error = false;
20
-			} else {
20
+			}else {
21 21
 				$error = 'dns';
22 22
 			}
23
-		} else {
23
+		}else {
24 24
 			$error = 'format';
25 25
 		}
26 26
 		return $error;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	function get_user_ip($out = '127.0.0.1')
219 219
 	{
220
-		$_getEnv = function ($data) {
220
+		$_getEnv = function($data) {
221 221
 			switch (true) {
222 222
 				case (isset($_SERVER[$data])):
223 223
 					$out = $_SERVER[$data];
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 				$output .= fgets($conn, 128);
358 358
 			}
359 359
 			fclose($conn);
360
-		} else {
360
+		}else {
361 361
 			throw new ErrorException('Could not connect to ' . $nic_server . '!');
362 362
 		}
363 363
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	function image_size($image, $mode = null)
439 439
 	{
440 440
 		$width = $height = 0;
441
-		if(is_scalar($image) && is_file($image)){
441
+		if (is_scalar($image) && is_file($image)) {
442 442
 			$size = @getimagesize($image);
443 443
 			$width = isset($size[0]) ? $size[0] : 0;
444 444
 			$height = isset($size[1]) ? $size[1] : 0;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	}
478 478
 }
479 479
 
480
-if(!function_exists('validate_date')){
480
+if (!function_exists('validate_date')) {
481 481
 	/**
482 482
 	 * Проверка валидности даты
483 483
 	 *
@@ -493,13 +493,13 @@  discard block
 block discarded – undo
493 493
 	 * @param Closure $validator метод для дополнительной проверки даты
494 494
 	 * @return null|string
495 495
 	 */
496
-	function validate_date($date, $fromFormat='Y-m-d', $toFormat = 'Y-m-d', Closure $validator = null){
496
+	function validate_date($date, $fromFormat = 'Y-m-d', $toFormat = 'Y-m-d', Closure $validator = null) {
497 497
 		$validTime = false;
498 498
 		$datetime2 = null;
499
-		if(is_scalar($date)){
499
+		if (is_scalar($date)) {
500 500
 			$datetime1 = new \DateTime("NOW");
501 501
 			$datetime2 = \DateTime::createFromFormat($fromFormat, $date);
502
-			if($datetime2 instanceof \DateTime){
502
+			if ($datetime2 instanceof \DateTime) {
503 503
 				$interval = $datetime1->diff($datetime2);
504 504
 				$validTime = is_callable($validator) ? (bool)$validator($datetime2, $interval) : true;
505 505
 			}
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 		return $validTime ? $datetime2->format($toFormat) : null;
508 508
 	}
509 509
 }
510
-if(!function_exists('format_bytes')){
510
+if (!function_exists('format_bytes')) {
511 511
 	/**
512 512
 	 * Преобразование из байт в другие порядки (кило, мега, гига) с добавлением префикса
513 513
 	 *
@@ -518,23 +518,23 @@  discard block
 block discarded – undo
518 518
 	 */
519 519
 	function format_bytes($bytes, $precision = 2, $suffixes = array('Байт', 'Кбайт', 'Мбайт', 'Гбайт', 'Тбайт')) {
520 520
 		$bytes = (float)$bytes;
521
-		if(empty($bytes)) return 0;
521
+		if (empty($bytes)) return 0;
522 522
 		$base = log($bytes, 1024);
523
-		return trim(round(pow(1024, $base - floor($base)), $precision) . ' ' .get_key($suffixes, (int)$base, '', 'is_scalar'));
523
+		return trim(round(pow(1024, $base - floor($base)), $precision) . ' ' . get_key($suffixes, (int)$base, '', 'is_scalar'));
524 524
 	}
525 525
 }
526 526
 
527
-if(!function_exists('format_microtime')){
527
+if (!function_exists('format_microtime')) {
528 528
 	/**
529 529
 	 * Форматирование microtime времени
530 530
 	 * @param string $time microtime время 
531 531
 	 * @param int $len Кол-во символов после точки
532 532
 	 */
533
-	function format_microtime($time, $len = 4){
534
-		return sprintf("%.".(int)$len."f", $time);
533
+	function format_microtime($time, $len = 4) {
534
+		return sprintf("%." . (int)$len . "f", $time);
535 535
 	}
536 536
 }
537
-if(!function_exists('ip_in_range')){
537
+if (!function_exists('ip_in_range')) {
538 538
 	/**
539 539
 	 * Входит ли указанный IP в заданный диапазон
540 540
 	 *
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	 * @param string $upper Конечный IP диапазона
544 544
 	 * @return bool
545 545
 	 */
546
-	function in_ip_range($ip, $lower, $upper){
546
+	function in_ip_range($ip, $lower, $upper) {
547 547
         return (ip2long($lower) <= ip2long($ip) && ip2long($upper) >= ip2long($ip)) ? TRUE : FALSE;
548 548
     }
549 549
 }
550 550
\ No newline at end of file
Please login to merge, or discard this patch.