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.

Button_List_Table::prepare_items()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 28
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 14
c 2
b 1
f 0
nc 2
nop 0
dl 0
loc 28
rs 9.7998
1
<?php
0 ignored issues
show
introduced by
Filenames should be all lowercase with hyphens as word separators. Expected buttons-list-table.php, but found buttons_list_table.php.
Loading history...
introduced by
Class file names should be based on the class name with "class-" prepended. Expected class-button-list-table.php, but found buttons_list_table.php.
Loading history...
Coding Style introduced by
This file is missing a doc comment.
Loading history...
2
namespace PodloveSubscribeButton;
3
4
if( ! class_exists( 'WP_List_Table' ) ){
0 ignored issues
show
introduced by
Space after opening control structure is required
Loading history...
introduced by
No space before opening parenthesis is prohibited
Loading history...
introduced by
Space between opening control structure and closing parenthesis is required
Loading history...
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
5
    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
0 ignored issues
show
Coding Style introduced by
"require_once" is a statement not a function; no parentheses are required
Loading history...
6
}
7
8
class Button_List_Table extends \WP_List_Table {
0 ignored issues
show
Coding Style introduced by
Class name "Button_List_Table" is not in PascalCase format

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
Coding Style Documentation introduced by
Missing doc comment for class Button_List_Table
Loading history...
9
10
	function __construct(){
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function __construct()
Loading history...
Best Practice introduced by
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 __construct.

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...
Coding Style introduced by
Expected 1 space before opening brace; found 0
Loading history...
11
		global $status, $page;
12
13
		// Set parent defaults
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
14
		parent::__construct( array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
15
		    'singular'  => 'feed',   // singular name of the listed records
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Array double arrow not aligned correctly; expected 1 space(s) between "'singular'" and double arrow, but found 2.
Loading history...
16
		    'plural'    => 'feeds',  // plural name of the listed records
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Array double arrow not aligned correctly; expected 3 space(s) between "'plural'" and double arrow, but found 4.
Loading history...
17
		    'ajax'      => false  // does this table support ajax?
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 5 space(s) between "'ajax'" and double arrow, but found 6.
Loading history...
introduced by
Each array item in a multi-line array declaration must end in a comma
Loading history...
18
		) );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
19
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
20
21
	function column_name( $button ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function column_name()
Loading history...
Best Practice introduced by
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...
Coding Style introduced by
Method name "Button_List_Table::column_name" is not in camel caps format
Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for column_name.

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...
22
23
		$actions = array(
24
			'edit'   => Settings\Buttons::get_action_link( $button, __( 'Edit', 'podlove-subscribe-button' ), 'edit' ),
25
			'delete' => Settings\Buttons::get_action_link( $button, __( 'Delete', 'podlove-subscribe-button' ), 'confirm_delete' )
0 ignored issues
show
introduced by
Each array item in a multi-line array declaration must end in a comma
Loading history...
26
		);
27
28
		return sprintf('%1$s %2$s',
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
29
		    /*$1%s*/ sanitize_title($button->title) . '<br><code>[podlove-subscribe-button button="' . sanitize_text_field($button->name) . '"]</code>',
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
30
		    /*$3%s*/ $this->row_actions( $actions )
31
		);
32
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
33
34
	function column_button_preview( $button ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function column_button_preview()
Loading history...
Best Practice introduced by
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...
Coding Style introduced by
Method name "Button_List_Table::column_button_preview" is not in camel caps format
Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for column_button_preview.

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...
35
36
		if ( ! $button->feeds ) {
37
			return '<code>' . __( 'No preview. Please set a feed.', 'podlove-subscribe-button' ) . '</code>';
38
		} else {
39
40
			$preview = "<div class='podlove-button-preview-container'>";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
41
			$preview .= $button->render(
42
				'big',
43
				'false',
44
				get_option( 'podlove_subscribe_button_default_style', 'filled' ),
45
				'rectangle'
46
			);
47
			$preview .= "</div>";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal </div> 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...
48
49
			return $preview;
50
51
		}
52
53
	}
54
55
56
	function column_id( $button ) {
0 ignored issues
show
Best Practice introduced by
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...
Coding Style introduced by
Method name "Button_List_Table::column_id" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function column_id()
Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for column_id.

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...
57
		return $button->id;
58
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
59
60
	function get_columns(){
0 ignored issues
show
Best Practice introduced by
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...
Coding Style introduced by
Method name "Button_List_Table::get_columns" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function get_columns()
Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for get_columns.

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...
Coding Style introduced by
Expected 1 space before opening brace; found 0
Loading history...
61
		return array(
62
			'name'    => __( 'Title & Shortcode', 'podlove-subscribe-button' ),
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 11 space(s) between "'name'" and double arrow, but found 4.
Loading history...
63
			'button_preview'    => __( 'Preview', 'podlove-subscribe-button' ),
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 1 space(s) between "'button_preview'" and double arrow, but found 4.
Loading history...
64
		);
65
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
66
67
	function prepare_items() {
0 ignored issues
show
Best Practice introduced by
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...
Coding Style introduced by
Method name "Button_List_Table::prepare_items" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function prepare_items()
Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for prepare_items.

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
		// number of items per page
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
69
		$per_page = 1000;
70
71
		// define column headers
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
72
		$columns = $this->get_columns();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
73
		$hidden = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 16 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
74
		$sortable = $this->get_sortable_columns();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 14 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
75
		$this->_column_headers = array( $columns, $hidden, $sortable );
76
77
		// retrieve data
78
		// TODO select data for current page only
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
79
		$data = ( is_network_admin() ? \PodloveSubscribeButton\Model\NetworkButton::all() : \PodloveSubscribeButton\Model\Button::all() );
80
81
		// get current page
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
82
		$current_page = $this->get_pagenum();
83
		// get total items
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
84
		$total_items = count( $data );
85
		// extrage page for current page only
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
86
		$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ) , $per_page );
0 ignored issues
show
Coding Style introduced by
Space found before comma in argument list
Loading history...
87
		// add items to table
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
88
		$this->items = $data;
89
90
		// register pagination options & calculations
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
91
		$this->set_pagination_args( array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
92
		    'total_items' => $total_items,
93
		    'per_page'    => $per_page,
94
		    'total_pages' => ceil( $total_items / $per_page )
0 ignored issues
show
introduced by
Each array item in a multi-line array declaration must end in a comma
Loading history...
95
		) );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
96
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
97
98
}
99