MatthewMi11er/wordpress-plugin-mi11er-utility

View on GitHub
includes/mi11er-utility/class-file-handler.php

Summary

Maintainability
A
1 hr
Test Coverage

Showing 17 of 17 total issues

Method the_posts_filter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function the_posts_filter( $posts, $wp_query ) {
$file_config = $this->get_config();
if ( false !== $file_config && $wp_query->is_main_query() && ! is_admin() ) {
$default_post = [
'post_author' => 1,
Severity: Minor
Found in includes/mi11er-utility/class-file-handler.php - About 1 hr to fix

Method add_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
Severity: Minor
Found in includes/mi11er-utility/class-file-handler.php - About 35 mins to fix

The method add_config has a boolean flag argument $prevent_slash, which is a certain sign of a Single Responsibility Principle violation.
Open

public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {

Avoid assigning values to variables in if clauses and the like (line '106', column '18').
Open

public function template_include_filter( $template ) {
// Check if we're dealing stuff care about.
if ( false !== $file_config = $this->get_config() ) {
return $file_config['template'];
}

Avoid unused parameters such as '$requested_url'.
Open

public function redirect_canonical_filter( $redirect_url, $requested_url ) {

The parameter $prevent_slash is not named in camelCase.
Open

public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
$this->_files[] = [
'file' => $file,
'rewrite' => $rewrite,
'template' => $template,

The class File_Handler is not named in CamelCase.
Open

class File_Handler implements Plugin_Interface
{
/**
* List of files that this plugin will handle.
*

The parameter $requested_url is not named in camelCase.
Open

public function redirect_canonical_filter( $redirect_url, $requested_url ) {
// Check if we're dealing stuff we care about and optionally prevent addtion of trailing slash.
if ( false !== $this->get_config() && $this->get_config()['prevent_slash'] ) {
return false;
}

The parameter $wp_query is not named in camelCase.
Open

public function the_posts_filter( $posts, $wp_query ) {
$file_config = $this->get_config();
if ( false !== $file_config && $wp_query->is_main_query() && ! is_admin() ) {
$default_post = [
'post_author' => 1,

The parameter $redirect_url is not named in camelCase.
Open

public function redirect_canonical_filter( $redirect_url, $requested_url ) {
// Check if we're dealing stuff we care about and optionally prevent addtion of trailing slash.
if ( false !== $this->get_config() && $this->get_config()['prevent_slash'] ) {
return false;
}

The property $_files is not named in camelCase.
Open

class File_Handler implements Plugin_Interface
{
/**
* List of files that this plugin will handle.
*

The method redirect_canonical_filter is not named in camelCase.
Open

public function redirect_canonical_filter( $redirect_url, $requested_url ) {
// Check if we're dealing stuff we care about and optionally prevent addtion of trailing slash.
if ( false !== $this->get_config() && $this->get_config()['prevent_slash'] ) {
return false;
}

The method template_include_filter is not named in camelCase.
Open

public function template_include_filter( $template ) {
// Check if we're dealing stuff care about.
if ( false !== $file_config = $this->get_config() ) {
return $file_config['template'];
}

The method get_config is not named in camelCase.
Open

public function get_config() {
$file_key = get_query_var( 'mu_file_handler', false );
if ( false !== $file_key && array_key_exists( $file_key, $this->_files ) ) {
return $this->_files[ $file_key ];
}

The method the_posts_filter is not named in camelCase.
Open

public function the_posts_filter( $posts, $wp_query ) {
$file_config = $this->get_config();
if ( false !== $file_config && $wp_query->is_main_query() && ! is_admin() ) {
$default_post = [
'post_author' => 1,

The method init_action is not named in camelCase.
Open

public function init_action() {
/**
* Fires on WordPress init, other themes and plugins to use this to handle their files.
*
* @param File_Handler $this File_Handler instance.

The method add_config is not named in camelCase.
Open

public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
$this->_files[] = [
'file' => $file,
'rewrite' => $rewrite,
'template' => $template,
Category
Status