Passed
Push — master ( bfbffa...ac9aa8 )
by
unknown
09:32
created
includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/Autoloader.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
      */
14 14
     public function __construct($baseDirectory = __DIR__)
15 15
     {
16
-        $this->directory = $baseDirectory;
17
-        $this->prefix = __NAMESPACE__ . '\\';
18
-        $this->prefixLength = strlen($this->prefix);
16
+	$this->directory = $baseDirectory;
17
+	$this->prefix = __NAMESPACE__ . '\\';
18
+	$this->prefixLength = strlen($this->prefix);
19 19
     }
20 20
 
21 21
     /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public static function register($prepend = false)
27 27
     {
28
-        spl_autoload_register(array(new self, 'autoload'), true, $prepend);
28
+	spl_autoload_register(array(new self, 'autoload'), true, $prepend);
29 29
     }
30 30
 
31 31
     /**
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function autoload($className)
37 37
     {
38
-        if (0 === strpos($className, $this->prefix)) {
39
-            $parts = explode('\\', substr($className, $this->prefixLength));
40
-            $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
38
+	if (0 === strpos($className, $this->prefix)) {
39
+	    $parts = explode('\\', substr($className, $this->prefixLength));
40
+	    $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
41 41
 
42
-            if (is_file($filepath)) {
43
-                require($filepath);
44
-            }
45
-        }
42
+	    if (is_file($filepath)) {
43
+		require($filepath);
44
+	    }
45
+	}
46 46
     }
47 47
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
     /**
12 12
      * @param string $baseDirectory Base directory where the source files are located.
13 13
      */
14
-    public function __construct($baseDirectory = __DIR__)
14
+    public function __construct( $baseDirectory = __DIR__ )
15 15
     {
16 16
         $this->directory = $baseDirectory;
17 17
         $this->prefix = __NAMESPACE__ . '\\';
18
-        $this->prefixLength = strlen($this->prefix);
18
+        $this->prefixLength = strlen( $this->prefix );
19 19
     }
20 20
 
21 21
     /**
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @param bool $prepend Prepend the autoloader on the stack instead of appending it.
25 25
      */
26
-    public static function register($prepend = false)
26
+    public static function register( $prepend = false )
27 27
     {
28
-        spl_autoload_register(array(new self, 'autoload'), true, $prepend);
28
+        spl_autoload_register( array( new self, 'autoload' ), true, $prepend );
29 29
     }
30 30
 
31 31
     /**
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @param string $className Fully qualified name of a class.
35 35
      */
36
-    public function autoload($className)
36
+    public function autoload( $className )
37 37
     {
38
-        if (0 === strpos($className, $this->prefix)) {
39
-            $parts = explode('\\', substr($className, $this->prefixLength));
40
-            $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
38
+        if ( 0 === strpos( $className, $this->prefix ) ) {
39
+            $parts = explode( '\\', substr( $className, $this->prefixLength ) );
40
+            $filepath = $this->directory . DIRECTORY_SEPARATOR . implode( DIRECTORY_SEPARATOR, $parts ) . '.php';
41 41
 
42
-            if (is_file($filepath)) {
43
-                require($filepath);
42
+            if ( is_file( $filepath ) ) {
43
+                require( $filepath );
44 44
             }
45 45
         }
46 46
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace PHPInsight;
4 4
 
5
-class Autoloader
6
-{
5
+class Autoloader {
7 6
     private $directory;
8 7
     private $prefix;
9 8
     private $prefixLength;
@@ -11,8 +10,7 @@  discard block
 block discarded – undo
11 10
     /**
12 11
      * @param string $baseDirectory Base directory where the source files are located.
13 12
      */
14
-    public function __construct($baseDirectory = __DIR__)
15
-    {
13
+    public function __construct($baseDirectory = __DIR__) {
16 14
         $this->directory = $baseDirectory;
17 15
         $this->prefix = __NAMESPACE__ . '\\';
18 16
         $this->prefixLength = strlen($this->prefix);
@@ -23,8 +21,7 @@  discard block
 block discarded – undo
23 21
      *
24 22
      * @param bool $prepend Prepend the autoloader on the stack instead of appending it.
25 23
      */
26
-    public static function register($prepend = false)
27
-    {
24
+    public static function register($prepend = false) {
28 25
         spl_autoload_register(array(new self, 'autoload'), true, $prepend);
29 26
     }
30 27
 
@@ -33,8 +30,7 @@  discard block
 block discarded – undo
33 30
      *
34 31
      * @param string $className Fully qualified name of a class.
35 32
      */
36
-    public function autoload($className)
37
-    {
33
+    public function autoload($className) {
38 34
         if (0 === strpos($className, $this->prefix)) {
39 35
             $parts = explode('\\', substr($className, $this->prefixLength));
40 36
             $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
Please login to merge, or discard this patch.
includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/Sentiment.php 2 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * Classification of opinions
66 66
 	 * @var array
67 67
 	 */
68
-	private $classes = array('pos', 'neg', 'neu');
68
+	private $classes = array( 'pos', 'neg', 'neu' );
69 69
 
70 70
 	/**
71 71
 	 * Token score per class
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 * @param str $dataFolder base folder
115 115
 	 * Sets defaults and loads/caches dictionaries
116 116
 	 */
117
-	public function __construct($dataFolder = false) {
117
+	public function __construct( $dataFolder = false ) {
118 118
 
119 119
 		//set the base folder for the data models
120
-		$this->setDataFolder($dataFolder);
120
+		$this->setDataFolder( $dataFolder );
121 121
 
122 122
 		//load and cache directories, get ignore and prefix lists
123 123
 		$this->loadDefaults();
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 * @param str $sentence Text to analyze
130 130
 	 * @return int Score
131 131
 	 */
132
-	public function score($sentence) {
132
+	public function score( $sentence ) {
133 133
 
134 134
 		//For each negative prefix in the list
135
-		foreach ($this->negPrefixList as $negPrefix) {
135
+		foreach ( $this->negPrefixList as $negPrefix ) {
136 136
 
137 137
 			//Search if that prefix is in the document
138
-			if (strpos($sentence, $negPrefix) !== false) {
138
+			if ( strpos( $sentence, $negPrefix ) !== false ) {
139 139
 				//Reove the white space after the negative prefix
140
-				$sentence = str_replace($negPrefix . ' ', $negPrefix, $sentence);
140
+				$sentence = str_replace( $negPrefix . ' ', $negPrefix, $sentence );
141 141
 			}
142 142
 		}
143 143
 
144 144
 		//Tokenise Document
145
-		$tokens = $this->_getTokens($sentence);
145
+		$tokens = $this->_getTokens( $sentence );
146 146
 		// calculate the score in each category
147 147
 
148 148
 		$total_score = 0;
@@ -151,18 +151,18 @@  discard block
 block discarded – undo
151 151
 		$scores = array();
152 152
 
153 153
 		//Loop through all of the different classes set in the $classes variable
154
-		foreach ($this->classes as $class) {
154
+		foreach ( $this->classes as $class ) {
155 155
 
156 156
 			//In the scores array add another dimention for the class and set it's value to 1. EG $scores->neg->1
157 157
 			$scores[$class] = 1;
158 158
 
159 159
 			//For each of the individual words used loop through to see if they match anything in the $dictionary
160
-			foreach ($tokens as $token) {
160
+			foreach ( $tokens as $token ) {
161 161
 
162 162
 				//If statement so to ignore tokens which are either too long or too short or in the $ignoreList
163
-				if (strlen($token) > $this->minTokenLength && strlen($token) < $this->maxTokenLength && !in_array($token, $this->ignoreList)) {
163
+				if ( strlen( $token ) > $this->minTokenLength && strlen( $token ) < $this->maxTokenLength && ! in_array( $token, $this->ignoreList ) ) {
164 164
 					//If dictionary[token][class] is set
165
-					if (isset($this->dictionary[$token][$class])) {
165
+					if ( isset( $this->dictionary[$token][$class] ) ) {
166 166
 						//Set count equal to it
167 167
 						$count = $this->dictionary[$token][$class];
168 168
 					} else {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 					}
171 171
 
172 172
 					//Score[class] is calcumeted by $scores[class] x $count +1 divided by the $classTokCounts[class] + $tokCount
173
-					$scores[$class] *= ($count + 1);
173
+					$scores[$class] *= ( $count + 1 );
174 174
 				}
175 175
 			}
176 176
 
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
 		}
180 180
 
181 181
 		//Makes the scores relative percents
182
-		foreach ($this->classes as $class) {
182
+		foreach ( $this->classes as $class ) {
183 183
 			$total_score += $scores[$class];
184 184
 		}
185 185
 
186
-		foreach ($this->classes as $class) {
187
-			$scores[$class] = round($scores[$class] / $total_score, 3);
186
+		foreach ( $this->classes as $class ) {
187
+			$scores[$class] = round( $scores[$class] / $total_score, 3 );
188 188
 		}
189 189
 
190 190
 		//Sort array in reverse order
191
-		arsort($scores);
191
+		arsort( $scores );
192 192
 
193 193
 		return $scores;
194 194
 	}
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 	 * @param str $sentence
200 200
 	 * @return str pos|neu|neg
201 201
 	 */
202
-	public function categorise($sentence) {
202
+	public function categorise( $sentence ) {
203 203
 
204
-		$scores = $this->score($sentence);
204
+		$scores = $this->score( $sentence );
205 205
 
206 206
 		//Classification is the key to the scores array
207
-		$classification = key($scores);
207
+		$classification = key( $scores );
208 208
 
209 209
 		return $classification;
210 210
 	}
@@ -215,30 +215,30 @@  discard block
 block discarded – undo
215 215
 	 * @param str $class
216 216
 	 * @return boolean
217 217
 	 */
218
-	public function setDictionary($class) {
218
+	public function setDictionary( $class ) {
219 219
 		/**
220 220
 		 *  For some people this file extention causes some problems!
221 221
 		 */
222 222
 		$fn = "{$this->dataFolder}data.{$class}.php";
223 223
 
224
-		if (file_exists($fn)) {
225
-			$temp = file_get_contents($fn);
226
-			$words = unserialize($temp);
224
+		if ( file_exists( $fn ) ) {
225
+			$temp = file_get_contents( $fn );
226
+			$words = unserialize( $temp );
227 227
 		} else {
228 228
 			echo 'File does not exist: ' . $fn;
229 229
 		}
230 230
 
231 231
 		//Loop through all of the entries
232
-		foreach ($words as $word) {
232
+		foreach ( $words as $word ) {
233 233
 
234 234
 			$this->docCount++;
235 235
 			$this->classDocCounts[$class]++;
236 236
 
237 237
 			//Trim word
238
-			$word = trim($word);
238
+			$word = trim( $word );
239 239
 
240 240
 			//If this word isn't already in the dictionary with this class
241
-			if (!isset($this->dictionary[$word][$class])) {
241
+			if ( ! isset( $this->dictionary[$word][$class] ) ) {
242 242
 
243 243
 				//Add to this word to the dictionary and set counter value as one. This function ensures that if a word is in the text file more than once it still is only accounted for one in the array
244 244
 				$this->dictionary[$word][$class] = 1;
@@ -256,22 +256,22 @@  discard block
 block discarded – undo
256 256
 	 * @param str  $dataFolder base folder
257 257
 	 * @param bool $loadDefaults true - load everything by default | false - just change the directory
258 258
 	 */
259
-	public function setDataFolder($dataFolder = false, $loadDefaults = false){
259
+	public function setDataFolder( $dataFolder = false, $loadDefaults = false ) {
260 260
 		//if $dataFolder not provided, load default, else set the provided one
261
-		if($dataFolder == false){
261
+		if ( $dataFolder == false ) {
262 262
 			$this->dataFolder = __DIR__ . '/data/';
263 263
 		}
264
-		else{
265
-			if(file_exists($dataFolder)){
264
+		else {
265
+			if ( file_exists( $dataFolder ) ) {
266 266
 				$this->dataFolder = $dataFolder;
267 267
 			}
268
-			else{
269
-				echo 'Error: could not find the directory - '.$dataFolder;
268
+			else {
269
+				echo 'Error: could not find the directory - ' . $dataFolder;
270 270
 			}
271 271
 		}
272 272
 
273 273
 		//load default directories, ignore and prefixe lists
274
-		if($loadDefaults !== false){
274
+		if ( $loadDefaults !== false ) {
275 275
 			$this->loadDefaults();
276 276
 		}
277 277
 	}
@@ -279,29 +279,29 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Load and cache directories, get ignore and prefix lists
281 281
 	 */
282
-	private function loadDefaults(){
282
+	private function loadDefaults() {
283 283
 		// Load and cache dictionaries
284
-		foreach ($this->classes as $class) {
285
-			if (!$this->setDictionary($class)) {
284
+		foreach ( $this->classes as $class ) {
285
+			if ( ! $this->setDictionary( $class ) ) {
286 286
 				echo "Error: Dictionary for class '$class' could not be loaded";
287 287
 			}
288 288
 		}
289 289
 
290
-		if (!isset($this->dictionary) || empty($this->dictionary))
290
+		if ( ! isset( $this->dictionary ) || empty( $this->dictionary ) )
291 291
 			echo 'Error: Dictionaries not set';
292 292
 
293 293
 		//Run function to get ignore list
294
-		$this->ignoreList = $this->getList('ign');
294
+		$this->ignoreList = $this->getList( 'ign' );
295 295
 
296 296
 		//If ingnoreList not get give error message
297
-		if (!isset($this->ignoreList))
297
+		if ( ! isset( $this->ignoreList ) )
298 298
 			echo 'Error: Ignore List not set';
299 299
 
300 300
 		//Get the list of negative prefixes
301
-		$this->negPrefixList = $this->getList('prefix');
301
+		$this->negPrefixList = $this->getList( 'prefix' );
302 302
 
303 303
 		//If neg prefix list not set give error
304
-		if (!isset($this->negPrefixList))
304
+		if ( ! isset( $this->negPrefixList ) )
305 305
 			echo 'Error: Ignore List not set';
306 306
 	}
307 307
 
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
 	 * @param str $string	String being broken up
312 312
 	 * @return array An array of tokens
313 313
 	 */
314
-	private function _getTokens($string) {
314
+	private function _getTokens( $string ) {
315 315
 
316 316
 		// Replace line endings with spaces
317
-		$string = str_replace("\r\n", " ", $string);
317
+		$string = str_replace( "\r\n", " ", $string );
318 318
 
319 319
 		//Clean the string so is free from accents
320
-		$string = $this->_cleanString($string);
320
+		$string = $this->_cleanString( $string );
321 321
 
322 322
 		//Make all texts lowercase as the database of words in in lowercase
323
-		$string = strtolower($string);
324
-		$string = preg_replace('/[[:punct:]]+/', '', $string);
323
+		$string = strtolower( $string );
324
+		$string = preg_replace( '/[[:punct:]]+/', '', $string );
325 325
 
326 326
 		//Break string into individual words using explode putting them into an array
327
-		$matches = explode(' ', $string);
327
+		$matches = explode( ' ', $string );
328 328
 
329 329
 		//Return array with each individual token
330 330
 		return $matches;
@@ -336,28 +336,28 @@  discard block
 block discarded – undo
336 336
 	 * @param str $type
337 337
 	 * @return array
338 338
 	 */
339
-	public function getList($type) {
339
+	public function getList( $type ) {
340 340
 		//Set up empty word list array
341 341
 		$wordList = array();
342 342
 
343 343
 		$fn = "{$this->dataFolder}data.{$type}.php";
344 344
 		;
345
-		if (file_exists($fn)) {
346
-			$temp = file_get_contents($fn);
347
-			$words = unserialize($temp);
345
+		if ( file_exists( $fn ) ) {
346
+			$temp = file_get_contents( $fn );
347
+			$words = unserialize( $temp );
348 348
 		} else {
349 349
 			return 'File does not exist: ' . $fn;
350 350
 		}
351 351
 
352 352
 		//Loop through results
353
-		foreach ($words as $word) {
353
+		foreach ( $words as $word ) {
354 354
 			//remove any slashes
355
-			$word = stripcslashes($word);
355
+			$word = stripcslashes( $word );
356 356
 			//Trim word
357
-			$trimmed = trim($word);
357
+			$trimmed = trim( $word );
358 358
 
359 359
 			//Push results into $wordList array
360
-			array_push($wordList, $trimmed);
360
+			array_push( $wordList, $trimmed );
361 361
 		}
362 362
 		//Return $wordList
363 363
 		return $wordList;
@@ -369,49 +369,49 @@  discard block
 block discarded – undo
369 369
 	 * @param str $string
370 370
 	 * @return str
371 371
 	 */
372
-	private function _cleanString($string) {
372
+	private function _cleanString( $string ) {
373 373
 
374 374
 		$diac =
375
-				/* A */ chr(192) . chr(193) . chr(194) . chr(195) . chr(196) . chr(197) .
376
-				/* a */ chr(224) . chr(225) . chr(226) . chr(227) . chr(228) . chr(229) .
377
-				/* O */ chr(210) . chr(211) . chr(212) . chr(213) . chr(214) . chr(216) .
378
-				/* o */ chr(242) . chr(243) . chr(244) . chr(245) . chr(246) . chr(248) .
379
-				/* E */ chr(200) . chr(201) . chr(202) . chr(203) .
380
-				/* e */ chr(232) . chr(233) . chr(234) . chr(235) .
381
-				/* Cc */ chr(199) . chr(231) .
382
-				/* I */ chr(204) . chr(205) . chr(206) . chr(207) .
383
-				/* i */ chr(236) . chr(237) . chr(238) . chr(239) .
384
-				/* U */ chr(217) . chr(218) . chr(219) . chr(220) .
385
-				/* u */ chr(249) . chr(250) . chr(251) . chr(252) .
386
-				/* yNn */ chr(255) . chr(209) . chr(241);
387
-
388
-		return strtolower(strtr($string, $diac, 'AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn'));
375
+				/* A */ chr( 192 ) . chr( 193 ) . chr( 194 ) . chr( 195 ) . chr( 196 ) . chr( 197 ) .
376
+				/* a */ chr( 224 ) . chr( 225 ) . chr( 226 ) . chr( 227 ) . chr( 228 ) . chr( 229 ) .
377
+				/* O */ chr( 210 ) . chr( 211 ) . chr( 212 ) . chr( 213 ) . chr( 214 ) . chr( 216 ) .
378
+				/* o */ chr( 242 ) . chr( 243 ) . chr( 244 ) . chr( 245 ) . chr( 246 ) . chr( 248 ) .
379
+				/* E */ chr( 200 ) . chr( 201 ) . chr( 202 ) . chr( 203 ) .
380
+				/* e */ chr( 232 ) . chr( 233 ) . chr( 234 ) . chr( 235 ) .
381
+				/* Cc */ chr( 199 ) . chr( 231 ) .
382
+				/* I */ chr( 204 ) . chr( 205 ) . chr( 206 ) . chr( 207 ) .
383
+				/* i */ chr( 236 ) . chr( 237 ) . chr( 238 ) . chr( 239 ) .
384
+				/* U */ chr( 217 ) . chr( 218 ) . chr( 219 ) . chr( 220 ) .
385
+				/* u */ chr( 249 ) . chr( 250 ) . chr( 251 ) . chr( 252 ) .
386
+				/* yNn */ chr( 255 ) . chr( 209 ) . chr( 241 );
387
+
388
+		return strtolower( strtr( $string, $diac, 'AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn' ) );
389 389
 	}
390 390
 
391 391
 	/**
392 392
 	 * Deletes old data/data.* files
393 393
 	 * Creates new files from updated source fi
394 394
 	 */
395
-	public function reloadDictionaries(){
395
+	public function reloadDictionaries() {
396 396
 
397
-		foreach($this->classes as $class){
397
+		foreach ( $this->classes as $class ) {
398 398
 			$fn = "{$this->dataFolder}data.{$class}.php";
399
-			if (file_exists($fn)) {
400
-				unlink($fn);
399
+			if ( file_exists( $fn ) ) {
400
+				unlink( $fn );
401 401
 			} 
402 402
 		}
403 403
 
404 404
 		$dictionaries = __DIR__ . '/dictionaries/';
405 405
 
406
-		foreach($this->classes as $class){
406
+		foreach ( $this->classes as $class ) {
407 407
 			$dict = "{$dictionaries}source.{$class}.php";
408 408
 
409
-			require_once($dict);
409
+			require_once( $dict );
410 410
 
411 411
 			$data = $class;
412 412
 
413 413
 			$fn = "{$this->dataFolder}data.{$class}.php";
414
-			file_put_contents($fn, serialize($$data));
414
+			file_put_contents( $fn, serialize( $$data ) );
415 415
 		}
416 416
 
417 417
 		
Please login to merge, or discard this patch.
Braces   +19 added lines, -18 removed lines patch added patch discarded remove patch
@@ -256,22 +256,20 @@  discard block
 block discarded – undo
256 256
 	 * @param str  $dataFolder base folder
257 257
 	 * @param bool $loadDefaults true - load everything by default | false - just change the directory
258 258
 	 */
259
-	public function setDataFolder($dataFolder = false, $loadDefaults = false){
259
+	public function setDataFolder($dataFolder = false, $loadDefaults = false) {
260 260
 		//if $dataFolder not provided, load default, else set the provided one
261
-		if($dataFolder == false){
261
+		if($dataFolder == false) {
262 262
 			$this->dataFolder = __DIR__ . '/data/';
263
-		}
264
-		else{
265
-			if(file_exists($dataFolder)){
263
+		} else {
264
+			if(file_exists($dataFolder)) {
266 265
 				$this->dataFolder = $dataFolder;
267
-			}
268
-			else{
266
+			} else {
269 267
 				echo 'Error: could not find the directory - '.$dataFolder;
270 268
 			}
271 269
 		}
272 270
 
273 271
 		//load default directories, ignore and prefixe lists
274
-		if($loadDefaults !== false){
272
+		if($loadDefaults !== false) {
275 273
 			$this->loadDefaults();
276 274
 		}
277 275
 	}
@@ -279,7 +277,7 @@  discard block
 block discarded – undo
279 277
 	/**
280 278
 	 * Load and cache directories, get ignore and prefix lists
281 279
 	 */
282
-	private function loadDefaults(){
280
+	private function loadDefaults() {
283 281
 		// Load and cache dictionaries
284 282
 		foreach ($this->classes as $class) {
285 283
 			if (!$this->setDictionary($class)) {
@@ -287,22 +285,25 @@  discard block
 block discarded – undo
287 285
 			}
288 286
 		}
289 287
 
290
-		if (!isset($this->dictionary) || empty($this->dictionary))
291
-			echo 'Error: Dictionaries not set';
288
+		if (!isset($this->dictionary) || empty($this->dictionary)) {
289
+					echo 'Error: Dictionaries not set';
290
+		}
292 291
 
293 292
 		//Run function to get ignore list
294 293
 		$this->ignoreList = $this->getList('ign');
295 294
 
296 295
 		//If ingnoreList not get give error message
297
-		if (!isset($this->ignoreList))
298
-			echo 'Error: Ignore List not set';
296
+		if (!isset($this->ignoreList)) {
297
+					echo 'Error: Ignore List not set';
298
+		}
299 299
 
300 300
 		//Get the list of negative prefixes
301 301
 		$this->negPrefixList = $this->getList('prefix');
302 302
 
303 303
 		//If neg prefix list not set give error
304
-		if (!isset($this->negPrefixList))
305
-			echo 'Error: Ignore List not set';
304
+		if (!isset($this->negPrefixList)) {
305
+					echo 'Error: Ignore List not set';
306
+		}
306 307
 	}
307 308
 
308 309
 	/**
@@ -392,9 +393,9 @@  discard block
 block discarded – undo
392 393
 	 * Deletes old data/data.* files
393 394
 	 * Creates new files from updated source fi
394 395
 	 */
395
-	public function reloadDictionaries(){
396
+	public function reloadDictionaries() {
396 397
 
397
-		foreach($this->classes as $class){
398
+		foreach($this->classes as $class) {
398 399
 			$fn = "{$this->dataFolder}data.{$class}.php";
399 400
 			if (file_exists($fn)) {
400 401
 				unlink($fn);
@@ -403,7 +404,7 @@  discard block
 block discarded – undo
403 404
 
404 405
 		$dictionaries = __DIR__ . '/dictionaries/';
405 406
 
406
-		foreach($this->classes as $class){
407
+		foreach($this->classes as $class) {
407 408
 			$dict = "{$dictionaries}source.{$class}.php";
408 409
 
409 410
 			require_once($dict);
Please login to merge, or discard this patch.
includes/gutenberg/headline-tool/phpinsight/autoload.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,6 +7,6 @@
 block discarded – undo
7 7
  * file that was distributed with this source code.
8 8
  */
9 9
 
10
-require __DIR__.'/lib/PHPInsight/Autoloader.php';
10
+require __DIR__ . '/lib/PHPInsight/Autoloader.php';
11 11
 
12 12
 PHPInsight\Autoloader::register();
Please login to merge, or discard this patch.
includes/gutenberg/headline-tool/phpinsight/examples/demo.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (PHP_SAPI != 'cli') {
2
+if ( PHP_SAPI != 'cli' ) {
3 3
 	echo "<pre>";
4 4
 }
5 5
 
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 
19 19
 require_once __DIR__ . '/../autoload.php';
20 20
 $sentiment = new \PHPInsight\Sentiment();
21
-foreach ($strings as $string) {
21
+foreach ( $strings as $string ) {
22 22
 
23 23
 	// calculations:
24
-	$scores = $sentiment->score($string);
25
-	$class = $sentiment->categorise($string);
24
+	$scores = $sentiment->score( $string );
25
+	$class = $sentiment->categorise( $string );
26 26
 
27 27
 	// output:
28 28
 	echo "String: $string\n";
29 29
 	echo "Dominant: $class, scores: ";
30
-	print_r($scores);
30
+	print_r( $scores );
31 31
 	echo "\n";
32 32
 }
Please login to merge, or discard this patch.
includes/admin/licensing/autoupdate.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		);
56 56
 		add_filter( "monsterinsights_is_autoupdate_setting_html_filtered_${plugin_file}", '__return_true' );
57 57
 	} elseif ( $has_permission &&
58
-	           ( $is_main_free || $is_main_pro || ( $is_addon && $is_pro ) )
58
+		   ( $is_main_free || $is_main_pro || ( $is_addon && $is_pro ) )
59 59
 	) {
60 60
 		$text  = __( 'Manage auto-updates', 'google-analytics-for-wordpress' );
61 61
 		$html .= '<br>' . sprintf( '<a href="%s"">%s</a>', admin_url( 'admin.php?page=monsterinsights_settings#/advanced' ), $text );
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
     // If this is multisite and is not on the main site, return early.
126 126
     if ( is_multisite() && ! is_main_site() ) {
127
-        return $update;
127
+	return $update;
128 128
     }
129 129
 
130 130
     // When used in the context of automatic plugin update routine, the $item
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 
133 133
     // If we don't have everything we need, return early.
134 134
     if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) {
135
-        return $update;
135
+	return $update;
136 136
     }
137 137
 
138 138
     // If the plugin isn't ours, return early.
139 139
     if ( ( ! $is_free && ! $is_paid ) || ( $is_free && ! defined( 'MONSTERINSIGHTS_LITE_VERSION' ) ) ) {
140
-        return $update;
140
+	return $update;
141 141
     }
142 142
 
143 143
     $version           = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version'];
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
 
147 147
     // If the opt in update allows major updates but there is no major version update, return early.
148 148
     if ( $current_major < $new_major ) {
149
-        if ( $automatic_updates === 'all' ) {
150
-            return true;
151
-        } else {
152
-            return $update;
153
-        }
149
+	if ( $automatic_updates === 'all' ) {
150
+	    return true;
151
+	} else {
152
+	    return $update;
153
+	}
154 154
     }
155 155
 
156 156
     // If the opt in update allows minor updates but there is no minor version update, return early.
157 157
     if ( $current_major == $new_major ) {
158
-        if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
159
-            return true;
160
-        } else {
161
-            return $update;
162
-        }
158
+	if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
159
+	    return true;
160
+	} else {
161
+	    return $update;
162
+	}
163 163
     }
164 164
 
165 165
     // All our checks have passed - this plugin can be updated!
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 function monsterinsights_get_major_version( $version ) {
198 198
     $exploded_version = explode( '.', $version );
199 199
     if ( isset( $exploded_version[2] ) ) {
200
-        return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
200
+	return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
201 201
     } else {
202
-        return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
202
+	return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
203 203
     }
204 204
 }
Please login to merge, or discard this patch.
includes/admin/licensing/skin-legacy.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function __construct( $args = array() ) {
27 27
 
28
-        parent::__construct();
28
+	parent::__construct();
29 29
 
30 30
     }
31 31
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function set_upgrader( &$upgrader ) {
40 40
 
41
-        if ( is_object( $upgrader ) ) {
42
-            $this->upgrader =& $upgrader;
43
-        }
41
+	if ( is_object( $upgrader ) ) {
42
+	    $this->upgrader =& $upgrader;
43
+	}
44 44
 
45 45
     }
46 46
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function set_result( $result ) {
55 55
 
56
-        $this->result = $result;
56
+	$this->result = $result;
57 57
 
58 58
     }
59 59
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     public function set_upgrader( &$upgrader ) {
40 40
 
41 41
         if ( is_object( $upgrader ) ) {
42
-            $this->upgrader =& $upgrader;
42
+            $this->upgrader = & $upgrader;
43 43
         }
44 44
 
45 45
     }
Please login to merge, or discard this patch.
includes/admin/licensing/plugin-upgrader-legacy.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -97,7 +97,8 @@  discard block
 block discarded – undo
97 97
 		 */
98 98
 		$options = apply_filters( 'upgrader_package_options', $options );
99 99
 
100
-		if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times
100
+		if ( ! $options['is_multi'] ) {
101
+// call $this->header separately if running multiple times
101 102
 			$this->skin->header();
102 103
 		}
103 104
 
@@ -288,7 +289,8 @@  discard block
 block discarded – undo
288 289
 			return $reply;
289 290
 		}
290 291
 
291
-		if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { //Local file or remote?
292
+		if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) {
293
+//Local file or remote?
292 294
 			return $package; //must be a local file..
293 295
 		}
294 296
 
@@ -443,11 +445,13 @@  discard block
 block discarded – undo
443 445
 		$remote_destination = $wp_filesystem->find_folder( $local_destination );
444 446
 
445 447
 		//Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
446
-		if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents.
448
+		if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
449
+//Only one folder? Then we want its contents.
447 450
 			$source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
448 451
 		} elseif ( count( $source_files ) == 0 ) {
449 452
 			return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files?
450
-		} else { // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename.
453
+		} else {
454
+// It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename.
451 455
 			$source = trailingslashit( $args['source'] );
452 456
 		}
453 457
 
Please login to merge, or discard this patch.
includes/frontend/tracking/class-tracking-analytics.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $create && ! empty( $create ) && is_array( $create ) ) {
100 100
 			$create = json_encode( $create );
101
-			$create = str_replace( '"', "'",  $create );
102
-			$options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create;
101
+			$create = str_replace( '"', "'", $create );
102
+			$options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "', " . $create;
103 103
 		} else {
104 104
 			$options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'";
105 105
 		}
@@ -191,37 +191,37 @@  discard block
 block discarded – undo
191 191
 	 * @return string Javascript to output.
192 192
 	 */
193 193
 	public function frontend_output( ) {
194
-		$options        = $this->frontend_tracking_options();
194
+		$options = $this->frontend_tracking_options();
195 195
 		$src     	    = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' );
196
-		$compat_mode     = monsterinsights_get_option( 'gatracker_compatibility_mode', false );
196
+		$compat_mode = monsterinsights_get_option( 'gatracker_compatibility_mode', false );
197 197
 		$compat    	 	= $compat_mode ? 'window.ga = __gaTracker;' : '';
198 198
 		$track_user 	= monsterinsights_track_user();
199 199
 		$ua         	= monsterinsights_get_ua();
200 200
 		$output     	= '';
201 201
 		$reason     	= '';
202
-		$attr_string    = monsterinsights_get_frontend_analytics_script_atts();
202
+		$attr_string = monsterinsights_get_frontend_analytics_script_atts();
203 203
 		ob_start();
204 204
 		?>
205 205
 <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ -->
206 206
 <?php if ( ! $track_user ) {
207 207
 	if ( empty( $ua ) ) {
208 208
 		$reason = __( 'Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress' );
209
-	    $output .=  '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
209
+	    $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
210 210
 	} else if ( current_user_can( 'monsterinsights_save_settings' ) ) {
211
-		$reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'. PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' );
212
-	    $output .=  '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
211
+		$reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.' . PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' );
212
+	    $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
213 213
 	} else {
214 214
 		$reason = __( 'Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress' );
215
-	    $output .=  '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
215
+	    $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
216 216
 	}
217 217
 	echo $output;
218 218
 } ?>
219 219
 <?php if ( $ua ) { ?>
220
-<script<?php echo $attr_string;?>>
220
+<script<?php echo $attr_string; ?>>
221 221
     (window.gaDevIds=window.gaDevIds||[]).push("dZGIzZG");
222 222
 	var mi_version         = '<?php echo MONSTERINSIGHTS_VERSION; ?>';
223 223
 	var mi_track_user      = <?php echo ( $track_user ? 'true' : 'false' ); ?>;
224
-	var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason)  . "'": "''" ); ?>;
224
+	var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason ) . "'" : "''" ); ?>;
225 225
 	<?php do_action( 'monsterinsights_tracking_analytics_frontend_output_after_mi_track_user' ); ?>
226 226
 
227 227
 <?php if ( $this->should_do_optout() ) { ?>
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	?>
276 276
 	} else {
277 277
 <?php if ( $this->should_do_optout() ) { ?>
278
-		console.log( "<?php echo esc_js( $reason );?>" );
278
+		console.log( "<?php echo esc_js( $reason ); ?>" );
279 279
 		(function() {
280 280
 			/* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */
281 281
 			var noopfn = function() {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 				}
299 299
 				var f = arguments[len-1];
300 300
 				if ( typeof f !== 'object' || f === null || typeof f.hitCallback !== 'function' ) {
301
-					console.log( '<?php echo esc_js( __("Not running function", "google-analytics-for-wordpress" ) );?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) );?> " + mi_no_track_reason );
301
+					console.log( '<?php echo esc_js( __( "Not running function", "google-analytics-for-wordpress" ) ); ?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) ); ?> " + mi_no_track_reason );
302 302
 					return;
303 303
 				}
304 304
 				try {
Please login to merge, or discard this patch.
includes/measurement-protocol.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
 
23 23
 	$defaults = array(
24 24
 		't'  => 'event', // Required: Hit type
25
-		'ec' => '',      // Optional: Event category
26
-		'ea' => '', 	 // Optional: Event Action
27
-		'el' => '', 	 // Optional: Event Label
28
-		'ev' => null, 	 // Optional: Event Value
25
+		'ec' => '', // Optional: Event category
26
+		'ea' => '', // Optional: Event Action
27
+		'el' => '', // Optional: Event Label
28
+		'ev' => null, // Optional: Event Value
29 29
 	);
30 30
 
31
-	$body  = array_merge( $defaults , $args );
31
+	$body = array_merge( $defaults, $args );
32 32
 
33 33
 	// We want to get the user's IP address when possible
34
-	$ip     = '';
34
+	$ip = '';
35 35
 	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) && ! filter_var( $_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP ) === false ) {
36 36
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
37 37
 	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && ! filter_var( $_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP ) === false ) {
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		'uip' => $ip,
80 80
 
81 81
 		// Optional: User Agent
82
-		'ua'  => ! empty( $user_agent ) ?  $user_agent : $_SERVER['HTTP_USER_AGENT'],
82
+		'ua'  => ! empty( $user_agent ) ? $user_agent : $_SERVER['HTTP_USER_AGENT'],
83 83
 
84 84
 		// Optional: Time of the event
85 85
 		'z'   => time(),
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	// Unset empty values to reduce request size
101 101
 	foreach ( $body as $key => $value ) {
102 102
 		if ( empty( $value ) ) {
103
-			unset( $body[ $key ] );
103
+			unset( $body[$key] );
104 104
 		}
105 105
 	}
106 106
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		// Optional: Event Value
139 139
 		'ev' => null,
140 140
 	);
141
-	$args  = wp_parse_args( $args, $default_args );
141
+	$args = wp_parse_args( $args, $default_args );
142 142
 	//$args = apply_filters( 'monsterinsights_mp_track_event_call', $args );
143 143
 
144 144
 	return monsterinsights_mp_api_call( $args );
Please login to merge, or discard this patch.