Completed
Push — master ( bd35ce...77e54d )
by Agel_Nash
03:39
created
src/utils.functions.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (!function_exists('supports_ansi_colors')) {	
3 3
 	/**
4
-	* Функция позволяет узнать, поддерживает ли консоль цвета и другое форматирование.
5
-	* @see: https://gostash.it/ru/stashes/1601-podderzivaet-li-konsol-cveta
6
-	* @return bool Результат проверки
7
-	* 
8
-	* DIRECTORY_SEPARATOR === '\\' — проверка на Windows.
9
-	* getenv('ANSICON') !== false — проверка запуска через ANSICON.
10
-	* getenv('ConEmuANSI') === 'ON' — проверка запуска через ConEmu.
11
-	* function_exists('posix_isatty') && @posix_isatty(\STDOUT) — проверка на интерактивный терминал UNIX.
12
-	*/
4
+	 * Функция позволяет узнать, поддерживает ли консоль цвета и другое форматирование.
5
+	 * @see: https://gostash.it/ru/stashes/1601-podderzivaet-li-konsol-cveta
6
+	 * @return bool Результат проверки
7
+	 * 
8
+	 * DIRECTORY_SEPARATOR === '\\' — проверка на Windows.
9
+	 * getenv('ANSICON') !== false — проверка запуска через ANSICON.
10
+	 * getenv('ConEmuANSI') === 'ON' — проверка запуска через ConEmu.
11
+	 * function_exists('posix_isatty') && @posix_isatty(\STDOUT) — проверка на интерактивный терминал UNIX.
12
+	 */
13 13
 	function supports_ansi_colors(){
14 14
 		return DIRECTORY_SEPARATOR === '\\'
15 15
 			? getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON'
@@ -570,25 +570,25 @@  discard block
 block discarded – undo
570 570
 	/**
571 571
 	 * Формирование правильной CSV строки
572 572
 	 *
573
-     	 * @see: https://stackoverflow.com/questions/3933668/convert-array-into-csv
573
+	 * @see: https://stackoverflow.com/questions/3933668/convert-array-into-csv
574 574
 	 * @param array $data Массив с данными
575 575
 	 * @return string
576 576
 	 */
577 577
 	function make_csv($data, $separator = ","){
578
-        	// Create a stream opening it with read / write mode
579
-        	$stream = fopen('data://text/plain,' . "", 'w+');
578
+			// Create a stream opening it with read / write mode
579
+			$stream = fopen('data://text/plain,' . "", 'w+');
580 580
 
581
-	        // Iterate over the data, writting each line to the text stream
582
-        	fputcsv($stream, $data, $separator);
581
+			// Iterate over the data, writting each line to the text stream
582
+			fputcsv($stream, $data, $separator);
583 583
 
584
-        	// Rewind the stream
585
-        	rewind($stream);
584
+			// Rewind the stream
585
+			rewind($stream);
586 586
 
587
-        	// You can now echo it's content
588
-        	$out = stream_get_contents($stream);
587
+			// You can now echo it's content
588
+			$out = stream_get_contents($stream);
589 589
 
590
-        	// Close the stream
591
-        	fclose($stream);
592
-        	return $out;
593
-    	}
590
+			// Close the stream
591
+			fclose($stream);
592
+			return $out;
593
+		}
594 594
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	* getenv('ConEmuANSI') === 'ON' — проверка запуска через ConEmu.
11 11
 	* function_exists('posix_isatty') && @posix_isatty(\STDOUT) — проверка на интерактивный терминал UNIX.
12 12
 	*/
13
-	function supports_ansi_colors(){
13
+	function supports_ansi_colors() {
14 14
 		return DIRECTORY_SEPARATOR === '\\'
15 15
 			? getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON'
16 16
 			: function_exists('posix_isatty') && @posix_isatty(\STDOUT);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	function get_gravatar($email, $size = 32)
108 108
 	{
109
-		$url = '//www.gravatar.com/avatar/' . md5(is_scalar($email) ? $email : '') . '?s=' . (int)abs($size);
109
+		$url = '//www.gravatar.com/avatar/'.md5(is_scalar($email) ? $email : '').'?s='.(int)abs($size);
110 110
 		return $url;
111 111
 	}
112 112
 }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	function share_vk($url, $title = '')
123 123
 	{
124
-		return 'http://vkontakte.ru/share.php?url=' . urlencode($url) . '&title=' . urlencode($title);
124
+		return 'http://vkontakte.ru/share.php?url='.urlencode($url).'&title='.urlencode($title);
125 125
 	}
126 126
 }
127 127
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	function share_ok($url, $title = '')
137 137
 	{
138
-		return 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl=' . urlencode($url) . '&st.comments=' . urlencode($title);
138
+		return 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl='.urlencode($url).'&st.comments='.urlencode($title);
139 139
 	}
140 140
 }
141 141
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	function share_google($url)
150 150
 	{
151
-		return 'https://plus.google.com/share?url=' . urlencode($url);
151
+		return 'https://plus.google.com/share?url='.urlencode($url);
152 152
 	}
153 153
 }
154 154
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	function share_facebook($url, $title = '')
164 164
 	{
165
-		return 'http://www.facebook.com/sharer/sharer.php?s=100&p[url]=' . urlencode($url) . '&p[title]=' . urlencode($title);
165
+		return 'http://www.facebook.com/sharer/sharer.php?s=100&p[url]='.urlencode($url).'&p[title]='.urlencode($title);
166 166
 	}
167 167
 }
168 168
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	function share_twitter($url, $title = '')
178 178
 	{
179
-		return 'https://twitter.com/intent/tweet?url=' . urlencode($url) . '&text=' . urlencode($title);
179
+		return 'https://twitter.com/intent/tweet?url='.urlencode($url).'&text='.urlencode($title);
180 180
 	}
181 181
 }
182 182
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	function share_mail($url, $title = '')
192 192
 	{
193
-		return 'http://connect.mail.ru/share?share_url=' . urlencode($url) . '&title=' . urlencode($title);
193
+		return 'http://connect.mail.ru/share?share_url='.urlencode($url).'&title='.urlencode($title);
194 194
 	}
195 195
 }
196 196
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	function share_linkedin($url, $title = '')
206 206
 	{
207
-		return 'http://www.linkedin.com/shareArticle?mini=true&url=' . urlencode($url) . '&title=' . urlencode($title);
207
+		return 'http://www.linkedin.com/shareArticle?mini=true&url='.urlencode($url).'&title='.urlencode($title);
208 208
 	}
209 209
 }
210 210
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	{
221 221
 		$size = (int)$size;
222 222
 		$size = implode("x", array($size, $size));
223
-		return '//chart.apis.google.com/chart?cht=qr&chs=' . $size . '&chl=' . (is_scalar($str) ? urlencode($str) : '');
223
+		return '//chart.apis.google.com/chart?cht=qr&chs='.$size.'&chl='.(is_scalar($str) ? urlencode($str) : '');
224 224
 	}
225 225
 }
226 226
 
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 
369 369
 		// connect to whois server:
370 370
 		if ($conn = fsockopen($nic_server, 43)) {
371
-			fputs($conn, $domain . "\r\n");
371
+			fputs($conn, $domain."\r\n");
372 372
 			while (!feof($conn)) {
373 373
 				$output .= fgets($conn, 128);
374 374
 			}
375 375
 			fclose($conn);
376 376
 		}else {
377
-			throw new ErrorException('Could not connect to ' . $nic_server . '!');
377
+			throw new ErrorException('Could not connect to '.$nic_server.'!');
378 378
 		}
379 379
 
380 380
 		return $output;
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	function copyright($year, $sep = ' - ')
393 393
 	{
394 394
 		$y = date('Y');
395
-		return ($y != $year) ? ($year . $sep . $y) : $year;
395
+		return ($y != $year) ? ($year.$sep.$y) : $year;
396 396
 	}
397 397
 }
398 398
 
@@ -534,25 +534,25 @@  discard block
 block discarded – undo
534 534
 	 */
535 535
 	function format_bytes($bytes, $precision = 2, $suffixes = array('Байт', 'Кбайт', 'Мбайт', 'Гбайт', 'Тбайт')) {
536 536
 		$bytes = (float)$bytes;
537
-		if(empty($bytes)) {
537
+		if (empty($bytes)) {
538 538
 			return 0;
539 539
 		}
540 540
 		$base = log($bytes, 1024);
541
-		return trim(round(pow(1024, $base - floor($base)), $precision) . ' ' .get_key($suffixes, (int)$base, '', 'is_scalar'));
541
+		return trim(round(pow(1024, $base - floor($base)), $precision).' '.get_key($suffixes, (int)$base, '', 'is_scalar'));
542 542
 	}
543 543
 }
544 544
 
545
-if(!function_exists('format_microtime')){
545
+if (!function_exists('format_microtime')) {
546 546
 	/**
547 547
 	 * Форматирование microtime времени
548 548
 	 * @param string $time microtime время 
549 549
 	 * @param int $len Кол-во символов после точки
550 550
 	 */
551
-	function format_microtime($time, $len = 4){
551
+	function format_microtime($time, $len = 4) {
552 552
 		return sprintf("%.".(int)$len."f", $time);
553 553
 	}
554 554
 }
555
-if(!function_exists('ip_in_range')){
555
+if (!function_exists('ip_in_range')) {
556 556
 	/**
557 557
 	 * Входит ли указанный IP в заданный диапазон
558 558
 	 *
@@ -561,12 +561,12 @@  discard block
 block discarded – undo
561 561
 	 * @param string $upper Конечный IP диапазона
562 562
 	 * @return bool
563 563
 	 */
564
-	function in_ip_range($ip, $lower, $upper){
564
+	function in_ip_range($ip, $lower, $upper) {
565 565
 		return (ip2long($lower) <= ip2long($ip) && ip2long($upper) >= ip2long($ip)) ? TRUE : FALSE;
566 566
 	}
567 567
 }
568 568
 
569
-if(!function_exists('make_csv')){
569
+if (!function_exists('make_csv')) {
570 570
 	/**
571 571
 	 * Формирование правильной CSV строки
572 572
 	 *
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 	 * @param array $data Массив с данными
575 575
 	 * @return string
576 576
 	 */
577
-	function make_csv($data, $separator = ","){
577
+	function make_csv($data, $separator = ",") {
578 578
         	// Create a stream opening it with read / write mode
579
-        	$stream = fopen('data://text/plain,' . "", 'w+');
579
+        	$stream = fopen('data://text/plain,'."", 'w+');
580 580
 
581 581
 	        // Iterate over the data, writting each line to the text stream
582 582
         	fputcsv($stream, $data, $separator);
Please login to merge, or discard this patch.