Passed
Push — master ( 0b7aa3...1e9d3c )
by Chris
08:25
created
includes/gutenberg/headline-tool/headline-tool.php 1 patch
Braces   +6 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since      0.1
12 12
  * @author     Debjit Saha
13 13
  */
14
-class MonsterInsightsHeadlineToolPlugin{
14
+class MonsterInsightsHeadlineToolPlugin {
15 15
 
16 16
 	/**
17 17
 	 * Class Variables.
@@ -154,21 +154,13 @@  discard block
 block discarded – undo
154 154
 		$result->length = strlen( str_replace( ' ', '', $input ) );
155 155
 		$scoret = $scoret + 3;
156 156
 
157
-		if ( $result->length <= 19 ) { $scoret += 5; }
158
-		elseif ( $result->length >= 20 && $result->length <= 34 ) { $scoret += 8; }
159
-		elseif ( $result->length >= 35 && $result->length <= 66 ) { $scoret += 11; }
160
-		elseif ( $result->length >= 67 && $result->length <= 79 ) { $scoret += 8; }
161
-		elseif ( $result->length >= 80 ) { $scoret += 5; }
157
+		if ( $result->length <= 19 ) { $scoret += 5; } elseif ( $result->length >= 20 && $result->length <= 34 ) { $scoret += 8; } elseif ( $result->length >= 35 && $result->length <= 66 ) { $scoret += 11; } elseif ( $result->length >= 67 && $result->length <= 79 ) { $scoret += 8; } elseif ( $result->length >= 80 ) { $scoret += 5; }
162 158
 
163 159
 		// Count - typically 6-7 words
164 160
 		$result->word_count = count( $input_array );
165 161
 		$scoret = $scoret + 3;
166 162
 
167
-		if ( $result->word_count == 0 ) { $scoret = 0; }
168
-		else if ( $result->word_count >= 2 && $result->word_count <= 4 ) { $scoret += 5; }
169
-		elseif ( $result->word_count >= 5 && $result->word_count <= 9 ) { $scoret += 11; }
170
-		elseif ( $result->word_count >= 10 && $result->word_count <= 11 ) { $scoret += 8; }
171
-		elseif ( $result->word_count >= 12 ) { $scoret += 5; }
163
+		if ( $result->word_count == 0 ) { $scoret = 0; } else if ( $result->word_count >= 2 && $result->word_count <= 4 ) { $scoret += 5; } elseif ( $result->word_count >= 5 && $result->word_count <= 9 ) { $scoret += 11; } elseif ( $result->word_count >= 10 && $result->word_count <= 11 ) { $scoret += 8; } elseif ( $result->word_count >= 12 ) { $scoret += 5; }
172 164
 
173 165
 		// Calculate word match counts
174 166
 		$result->power_words = $this->match_words( $result->input, $result->input_array, $this->power_words );
@@ -196,8 +188,9 @@  discard block
 block discarded – undo
196 188
 
197 189
 		if ( $result->uncommon_words_per < 0.1 ) {
198 190
 			$result->word_balance_use[] = __('uncommon', 'google-analytics-for-wordpress');
199
-		} else
200
-			$scoret = $scoret + 15;
191
+		} else {
192
+					$scoret = $scoret + 15;
193
+		}
201 194
 
202 195
 		if ( count( $result->power_words ) < 1 ) {
203 196
 			$result->word_balance_use[] = __('power', 'google-analytics-for-wordpress');
Please login to merge, or discard this patch.
includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/Autoloader.php 1 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 1 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/helpers.php 1 patch
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
 	return $countries;
888 888
 }
889 889
 
890
-function monsterinsights_get_api_url(){
890
+function monsterinsights_get_api_url() {
891 891
 	return apply_filters( 'monsterinsights_get_api_url', 'api.monsterinsights.com/v2/' );
892 892
 }
893 893
 
894
-function monsterinsights_get_licensing_url(){
894
+function monsterinsights_get_licensing_url() {
895 895
 	return apply_filters( 'monsterinsights_get_licensing_url', 'https://www.monsterinsights.com' );
896 896
 }
897 897
 
@@ -956,7 +956,9 @@  discard block
 block discarded – undo
956 956
 	function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
957 957
 		global $wp_filter;
958 958
 		// Check that filter actually exists first
959
-		if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
959
+		if ( ! isset( $wp_filter[ $tag ] ) ) {
960
+			return FALSE;
961
+		}
960 962
 		/**
961 963
 		 * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
962 964
 		 * a simple array, rather it is an object that implements the ArrayAccess interface.
@@ -971,23 +973,35 @@  discard block
 block discarded – undo
971 973
 			$callbacks = &$wp_filter[ $tag ];
972 974
 		}
973 975
 		// Exit if there aren't any callbacks for specified priority
974
-		if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
976
+		if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) {
977
+			return FALSE;
978
+		}
975 979
 		// Loop through each filter for the specified priority, looking for our class & method
976 980
 		foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
977 981
 			// Filter should always be an array - array( $this, 'method' ), if not goto next
978
-			if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
982
+			if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) {
983
+				continue;
984
+			}
979 985
 			// If first value in array is not an object, it can't be a class
980
-			if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
986
+			if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) {
987
+				continue;
988
+			}
981 989
 			// Method doesn't match the one we're looking for, goto next
982
-			if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
990
+			if ( $filter[ 'function' ][ 1 ] !== $method_name ) {
991
+				continue;
992
+			}
983 993
 			// Method matched, now let's check the Class
984 994
 			if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
985 995
 				// Now let's remove it from the array
986 996
 				unset( $callbacks[ $priority ][ $filter_id ] );
987 997
 				// and if it was the only filter in that priority, unset that priority
988
-				if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] );
998
+				if ( empty( $callbacks[ $priority ] ) ) {
999
+					unset( $callbacks[ $priority ] );
1000
+				}
989 1001
 				// and if the only filter for that tag, set the tag to an empty array
990
-				if ( empty( $callbacks ) ) $callbacks = array();
1002
+				if ( empty( $callbacks ) ) {
1003
+					$callbacks = array();
1004
+				}
991 1005
 				// If using WordPress older than 4.7
992 1006
 				if ( ! is_object( $wp_filter[ $tag ] ) ) {
993 1007
 					// Remove this filter from merged_filters, which specifies if filters have been sorted
@@ -1443,7 +1457,7 @@  discard block
 block discarded – undo
1443 1457
  *
1444 1458
  * @return trimed sentence
1445 1459
  */
1446
-function monsterinsights_trim_text( $text, $count ){
1460
+function monsterinsights_trim_text( $text, $count ) {
1447 1461
 	$text 	= str_replace("  ", " ", $text);
1448 1462
 	$string = explode(" ", $text);
1449 1463
 	$trimed = "";
@@ -1451,7 +1465,7 @@  discard block
 block discarded – undo
1451 1465
 	for ( $wordCounter = 0; $wordCounter <= $count; $wordCounter++ ) {
1452 1466
 		$trimed .= isset( $string[$wordCounter] ) ? $string[$wordCounter] : '';
1453 1467
 
1454
-		if ( $wordCounter < $count ){
1468
+		if ( $wordCounter < $count ) {
1455 1469
 			$trimed .= " ";
1456 1470
 		} else {
1457 1471
 			$trimed .= "...";
Please login to merge, or discard this patch.