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 — develop ( ec64d7...145ef0 )
by Chris
12s
created

namespace.php ➔ numbers_of_players()   B

Complexity

Conditions 4
Paths 3

Size

Total Lines 22
Code Lines 10

Duplication

Lines 14
Ratio 63.64 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 3
nop 3
dl 14
loc 22
ccs 9
cts 9
cp 1
crap 4
rs 8.9197
c 0
b 0
f 0
1
<?php
2
/**
3
 * Games Collector
4
 *
5
 * @package GC\GamesCollector
6
 */
7
8
namespace GC\GamesCollector;
9
10
/**
11
 * Hook all the things.
12
 *
13
 * @since  0.1
14
 */
15
function bootstrap() {
16
	// Add all your plugin hooks here.
17
	add_action( 'cmb2_init',               __NAMESPACE__ . '\\Game\\fields' );
18
	add_action( 'init',                    __NAMESPACE__ . '\\Game\\register_cpt' );
19
	add_action( 'init',                    __NAMESPACE__ . '\\Attributes\\register_taxonomy' );
20
	add_action( 'admin_init',              __NAMESPACE__ . '\\Attributes\\create_default_attributes' );
21
	add_action( 'add_meta_boxes',          __NAMESPACE__ . '\\Attributes\\metabox' );
22
	add_action( 'admin_enqueue_scripts',   __NAMESPACE__ . '\\Attributes\\enqueue_scripts' );
23
	add_action( 'wp_enqueue_scripts',      __NAMESPACE__ . '\\Display\\enqueue_scripts' );
24
	add_action( 'register_shortcode_ui',   __NAMESPACE__ . '\\Shortcode\\register_all_games_shortcode' );
25
	add_action( 'register_shortcode_ui',   __NAMESPACE__ . '\\Shortcode\\register_individual_games_shortcode' );
26
	add_filter( 'rest_prepare_gc_game',    __NAMESPACE__ . '\\Api\\filter_games_json', 10, 2 );
27
	add_filter( 'gc_filter_players',       __NAMESPACE__ . '\\numbers_of_players', 10, 3 );
28
	add_shortcode( 'games-collector',      __NAMESPACE__ . '\\Shortcode\\shortcode' );
29
	add_shortcode( 'games-collector-list', __NAMESPACE__ . '\\Shortcode\\shortcode' );
30
}
31
32
/**
33
 * Create a new page with the games-collector shortcode in it on activation if a Games page doesn't already exist.
34
 *
35
 * @since  1.1.0
36
 */
37
function activate() {
38 1
	if ( ! get_page_by_title( esc_html__( 'Games', 'games-collector' ) ) ) {
39 1
		wp_insert_post([
40 1
			'post_type'    => 'page',
41 1
			'post_title'   => esc_html__( 'Games', 'games-collector' ),
42 1
			'post_content' => '[games-collector]',
43 1
			'post_status'  => 'publish',
44
		] );
45
	}
46 1
}
47
48
/**
49
 * Update the number of players.
50
 *
51
 * Adds conditions for games with specific number of players only (e.g. 1 player, 2 players) or an indeterminate or very large number of players (e.g. 2+, 2-99 players).
52
 *
53
 * @since  1.2.0
54
 * @param  int    $game_id         The game's post ID.
55
 * @param  array  $players_min_max The minimum and maximum number of players.
56
 * @param  string $output          The player output.
57
 * @return string                  The filtered output.
58
 */
59
function numbers_of_players( $game_id, $players_min_max, $output ) {
0 ignored issues
show
Unused Code introduced by
The parameter $game_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
61
	// Deal with max number of players matching min number of players.
62 3 View Code Duplication
	if ( absint( $players_min_max['min'] ) === absint( $players_min_max['max'] ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63 1
		return esc_attr( sprintf(
64
			// Translators: %d is the number of players.
65 1
			_n( '%d player', '%d players', absint( $players_min_max['min'] ), 'games-collector' ),
66 1
			absint( $players_min_max['min'] )
67
		) );
68
	}
69
70
	// Deal with indeterminate or large number of max players.
71 3 View Code Duplication
	if ( 0 === absint( $players_min_max['max'] ) || 20 <= absint( $players_min_max['max'] ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72 1
		return esc_attr( sprintf(
73
			// Translators: %d is the minimum number players.
74 1
			__( '%d+ players', 'games-collector' ),
75 1
			absint( $players_min_max['min'] )
76
		) );
77
	}
78
79 2
	return $output;
80
}
81