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.
Completed
Push — master ( dc0f35...efd704 )
by Christian
15s
created

Helpers::get_basename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
0 ignored issues
show
introduced by
Filenames should be all lowercase with hyphens as word separators. Expected helpers.php, but found Helpers.php.
Loading history...
introduced by
Class file names should be based on the class name with "class-" prepended. Expected class-helpers.php, but found Helpers.php.
Loading history...
2
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
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
Coding Style introduced by
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
Coding Style introduced by
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
Coding Style introduced by
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 static function get_basename() {
0 ignored issues
show
Coding Style introduced by
Method name "Helpers::get_basename" is not in camel caps format
Loading history...
37
		return plugin_basename( \PodloveSubscribeButton::plugin_file() );
38
	} // END get_basename()
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
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
Coding Style introduced by
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
	} // END is_podlove_publisher_active()
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
52
53
	/**
54
	 * Get button compatible language string.
55
	 *
56
	 * Examples:
57
	 *
58
	 *  language('de');    // => 'de'
59
	 *  language('de_DE'); // => 'de'
60
	 *  language('en_GB'); // => 'en'
61
	 *
62
	 * @param  string $language language identifier
0 ignored issues
show
Coding Style Documentation introduced by
Parameter comment must end with a full stop
Loading history...
63
	 *
64
	 * @return string
65
	 */
66
	public static function language( $language ) {
67
		if ( empty( $language ) ) {
68
			$language = get_option( 'WPLANG' );
69
		}
70
71
		$lang_code = strtolower( explode( '_', $language )[0] );
72
73
		if ( in_array( $lang_code, \PodloveSubscribeButton\Defaults::button( 'language' ) ) ) {
0 ignored issues
show
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
74
			return $lang_code;
75
		} else {
76
			return 'en';
77
		}
78
	} // END language()
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
79
80
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$callback" missing
Loading history...
81
	 * Run a function for each site in its scope
82
	 *
83
	 * @param $callback
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
84
	 */
85
	public static function for_every_podcast_blog( $callback ) {
0 ignored issues
show
Coding Style introduced by
Method name "Helpers::for_every_podcast_blog" is not in camel caps format
Loading history...
86
		global $wpdb;
87
88
		$plugin  = self::get_basename();
89
		$blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs );
0 ignored issues
show
introduced by
Usage of a direct database call is discouraged.
Loading history...
introduced by
Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().
Loading history...
Coding Style Comprehensibility introduced by
The string literal SELECT blog_id FROM does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
90
91
		if ( ! is_array( $blogids ) ) {
92
			return;
93
		}
94
95
		foreach ( $blogids as $blog_id ) {
96
			switch_to_blog( $blog_id );
97
			if ( is_plugin_active( $plugin ) ) {
98
				$callback();
99
			}
100
			restore_current_blog();
101
		}
102
	} // END for_every_podcast_blog()
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
103
104
} // END Class
105