Issues (823)

classes/class-lsx-search.php (19 issues)

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 91.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * LSX Search Main Class.
4
 *
5
 * @package lsx-search
6
 */
7
class LSX_Search {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Class name "LSX_Search" 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...
8
9
	/**
10
	 * Holds class instance
11
	 *
12
	 * @since 1.0.0
13
	 *
14
	 * @var      object LSX_Search()
15
	 */
16
	protected static $instance = null;
17
18
	/**
19
	 * @var LSX_Search_Admin()
0 ignored issues
show
The type LSX_Search_Admin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
	 */
21
	public $admin;
22
23
	/**
24
	 * @var LSX_Search_Frontend()
0 ignored issues
show
The type LSX_Search_Frontend was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
	 */
26
	public $frontend;
27
28
	/**
29
	 * @var LSX_Search_FacetWP()
30
	 */
31
	public $facetwp;
32
33
	/**
34
	 * @var LSX_Search_Shortcode()
35
	 */
36
	public $shortcode;
37
38
	/**
39
	 * LSX_Search constructor
40
	 */
41
	public function __construct() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
42
		$this->load_vendors();
43
44
		require_once LSX_SEARCH_PATH . '/classes/class-admin.php';
45
		require_once LSX_SEARCH_PATH . '/classes/class-frontend.php';
46
		require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-facetwp.php';
47
		require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-shortcode.php';
48
49
		$this->admin     = \lsx\search\classes\Admin::get_instance();
50
		$this->frontend  = \lsx\search\classes\Frontend::get_instance();
51
		$this->facetwp   = new LSX_Search_FacetWP();
52
		$this->shortcode = new LSX_Search_Shortcode();
53
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
54
55
	/**
56
	 * Return an instance of this class.
57
	 *
58
	 * @since 1.0.0
59
	 *
60
	 * @return    object LSX_Search()    A single instance of this class.
61
	 */
62
	public static function get_instance() {
0 ignored issues
show
Method name "LSX_Search::get_instance" is not in camel caps format
Loading history...
63
		// If the single instance hasn't been set, set it now.
64
		if ( null === self::$instance ) {
0 ignored issues
show
Expected 0 spaces before closing bracket; 1 found
Loading history...
65
			self::$instance = new self();
66
		}
67
		return self::$instance;
68
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
69
70
	/**
71
	 * Loads the plugin functions.
72
	 */
73
	private function load_vendors() {
0 ignored issues
show
Method name "LSX_Search::load_vendors" is not in camel caps format
Loading history...
74
		// Configure custom fields.
75
		if ( ! class_exists( 'CMB2' ) ) {
0 ignored issues
show
Expected 0 spaces before closing bracket; 1 found
Loading history...
76
			require_once LSX_SEARCH_PATH . 'vendor/CMB2/init.php';
77
		}
78
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 0 found
Loading history...
79
}
80
81
/**
82
 * Initiates the LSX Search Plugin
83
 * 
84
 * @return object LSX_Search();
85
 */
86
function lsx_search() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
87
	global $lsx_search;
88
	$lsx_search = LSX_Search::get_instance();
89
	return $lsx_search;
90
}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 0 found
Loading history...
91
lsx_search();
92