GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 78b81a...d0a974 )
by Christian
02:32
created

inc/Helpers.php (22 issues)

1
<?php
0 ignored issues
show
Filenames should be all lowercase with hyphens as word separators. Expected helpers.php, but found Helpers.php.
Loading history...
Class file names should be based on the class name with "class-" prepended. Expected class-helpers.php, but found Helpers.php.
Loading history...
2
/**
3
 * @author    Podlove <[email protected]>
4
 * @copyright Copyright (c) 2014-2018, Podlove
5
 * @license   https://github.com/podlove/podlove-subscribe-button-wp-plugin/blob/master/LICENSE MIT
6
 * @package   Podlove\PodloveSubscribeButton
7
 */
8
9
namespace PodloveSubscribeButton;
10
11
Class Helpers {
0 ignored issues
show
As per coding-style, PHP keywords should be in lowercase; expected class, but found Class.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for class Helpers
Loading history...
12
13
	public static function get_path( $folder = '' ) {
0 ignored issues
show
Method name "Helpers::get_path" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function get_path()
Loading history...
14
15
		$path = untrailingslashit( plugin_dir_path( \PodloveSubscribeButton::plugin_file() ) );
16
17
		return $path . $folder;
18
19
	} // End get_path()
20
21
	public static function get_url( $path = '' ) {
0 ignored issues
show
Method name "Helpers::get_url" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function get_url()
Loading history...
22
23
		$url = trailingslashit( plugins_url( $path, \PodloveSubscribeButton::plugin_file() ) );
24
25
		return $url;
26
27
	} // End get_url()
28
29
	/**
30
	 * Get plugin basename
31
	 *
32
	 * @since  1.0.0
33
	 *
34
	 * @return string
35
	 */
36
	public function get_basename() {
0 ignored issues
show
Method name "Helpers::get_basename" is not in camel caps format
Loading history...
37
		return plugin_basename( \PodloveSubscribeButton::plugin_file() );
38
	} // get_basename()
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
40
	/**
41
	 * Check if `Podlove Publisher` is installed + activated
42
	 *
43
	 * @return bool
44
	 */
45
	public static function is_podlove_publisher_active() {
0 ignored issues
show
Method name "Helpers::is_podlove_publisher_active" is not in camel caps format
Loading history...
46
		if ( is_plugin_active( "podlove-podcasting-plugin-for-wordpress/podlove.php" ) ) {
47
			return true;
48
		}
49
50
		return false;
51
52
	}
53
54
	/**
55
	 * Get button compatible language string.
56
	 *
57
	 * Examples:
58
	 *
59
	 *  language('de');    // => 'de'
60
	 *  language('de_DE'); // => 'de'
61
	 *  language('en_GB'); // => 'en'
62
	 *
63
	 * @param  string $language language identifier
0 ignored issues
show
Coding Style Documentation introduced by
Parameter comment must end with a full stop
Loading history...
64
	 *
65
	 * @return string
66
	 */
67
	static function language( $language ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for language.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
68
69
		if ( empty( $language ) ) {
70
			$language = get_option( 'WPLANG' );
71
		}
72
73
		$lang_code = strtolower(explode('_', $language)[0]);
0 ignored issues
show
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
74
75
		if ( in_array( $lang_code, \PodloveSubscribeButton\Defaults::button('language' ) ) ) {
0 ignored issues
show
Not using strict comparison for in_array; supply true for third argument.
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
76
			return $lang_code;
77
		} else {
78
			return 'en';
79
		}
80
81
	}
82
83
	public static function for_every_podcast_blog( $callback ) {
0 ignored issues
show
Method name "Helpers::for_every_podcast_blog" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function for_every_podcast_blog()
Loading history...
84
85
		global $wpdb;
86
87
		/** @todo change to helper functionss */
0 ignored issues
show
Missing short description in doc comment
Loading history...
88
		$plugin  = basename( \PodloveSubscribeButton\PLUGIN_DIR ) . '/' . \PodloveSubscribeButton\PLUGIN_FILE_NAME;
89
		$blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs );
90
91
		if ( ! is_array( $blogids ) )
92
			return;
93
94
		foreach ( $blogids as $blog_id ) {
95
			switch_to_blog( $blog_id );
96
			if ( is_plugin_active( $plugin ) ) {
97
				$callback();
98
			}
99
			restore_current_blog();
100
		}
101
102
	}
103
104
} // END Class
105