Passed
Push — master ( d65707...db96c7 )
by Jean-Christophe
02:11
created
Ajax/common/traits/JsUtilsInternalTrait.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,14 +5,14 @@  discard block
 block discarded – undo
5 5
 
6 6
 trait JsUtilsInternalTrait {
7 7
 
8
-	protected $jquery_code_for_compile = array();
8
+	protected $jquery_code_for_compile=array();
9 9
 
10
-	protected $jquery_code_for_compile_at_last = array();
10
+	protected $jquery_code_for_compile_at_last=array();
11 11
 
12 12
 	protected $nonce;
13 13
 
14 14
 	protected function _addToCompile($jsScript) {
15
-		$this->jquery_code_for_compile[] = $jsScript;
15
+		$this->jquery_code_for_compile[]=$jsScript;
16 16
 	}
17 17
 
18 18
 	/**
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param BaseGui $library
21 21
 	 * @param mixed $view
22 22
 	 */
23
-	protected function _compileLibrary(BaseGui $library, &$view = NULL) {
23
+	protected function _compileLibrary(BaseGui $library, &$view=NULL) {
24 24
 		if (isset($view))
25 25
 			$library->compileHtml($this, $view);
26 26
 		if ($library->isAutoCompile()) {
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 
31 31
 	protected function defer($script) {
32
-		$result = "window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};";
33
-		$result .= "window.defer(function(){" . $script . "})";
32
+		$result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};";
33
+		$result.="window.defer(function(){".$script."})";
34 34
 		return $result;
35 35
 	}
36 36
 
37 37
 	protected function ready($script) {
38
-		$result = '$(document).ready(function() {' . "\n";
39
-		$result .= $script . '})';
38
+		$result='$(document).ready(function() {'."\n";
39
+		$result.=$script.'})';
40 40
 		return $result;
41 41
 	}
42 42
 
43 43
 	protected function minify($input) {
44
-		if (trim($input) === "")
44
+		if (trim($input)==="")
45 45
 			return $input;
46
-		$input = preg_replace(array(
46
+		$input=preg_replace(array(
47 47
 			// Remove comment(s)
48 48
 			'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
49 49
 			// Remove white-space(s) outside the string and regex
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			'$1$3',
62 62
 			'$1.$3'
63 63
 		), $input);
64
-		$input = str_replace("}$", "};$", $input);
64
+		$input=str_replace("}$", "};$", $input);
65 65
 		return $input;
66 66
 	}
67 67
 
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
 	 * @param string $src
72 72
 	 * @return string
73 73
 	 */
74
-	protected function _open_script($src = '') {
75
-		$str = '<script ';
76
-		if (! $this->isAjax() && isset($this->params['nonce'])) {
77
-			$nonce = $this->nonce ?? $this->generateNonce($this->params['nonce']);
78
-			$str .= ' nonce="' . $nonce . '" ';
74
+	protected function _open_script($src='') {
75
+		$str='<script ';
76
+		if (!$this->isAjax() && isset($this->params['nonce'])) {
77
+			$nonce=$this->nonce ?? $this->generateNonce($this->params['nonce']);
78
+			$str.=' nonce="'.$nonce.'" ';
79 79
 		}
80
-		$str .= ($src == '') ? '>' : ' src="' . $src . '">';
80
+		$str.=($src=='') ? '>' : ' src="'.$src.'">';
81 81
 		return $str;
82 82
 	}
83 83
 
84 84
 	protected function onNonce() {}
85 85
 
86
-	protected function generateNonce($value = null): string {
87
-		$bytes = \random_bytes((int) ($value ?? 32));
88
-		$this->nonce = \base64_encode($bytes);
86
+	protected function generateNonce($value=null): string {
87
+		$bytes=\random_bytes((int)($value ?? 32));
88
+		$this->nonce=\base64_encode($bytes);
89 89
 		$this->onNonce();
90 90
 		return $this->nonce;
91 91
 	}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param string $extra
101 101
 	 * @return string
102 102
 	 */
103
-	protected function _close_script($extra = "\n") {
103
+	protected function _close_script($extra="\n") {
104 104
 		return "</script>$extra";
105 105
 	}
106 106
 
@@ -113,6 +113,6 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 
115 115
 	public function isAjax(): bool {
116
-		return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
116
+		return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])=='xmlhttprequest');
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.