Issues (4138)

classes/frontend/class-modals.php (23 issues)

1
<?php
0 ignored issues
show
This file is missing a doc comment.
Loading history...
2
namespace lsx_health_plan\classes;
3
4
/**
5
 * Contains the endpoints
6
 *
7
 * @package lsx-health-plan
8
 */
9
class Modals {
10
11
	/**
12
	 * Holds class instance
13
	 *
14
	 * @since 1.0.0
15
	 *
16
	 * @var      object \lsx_health_plan\classes\Modals()
17
	 */
18
	protected static $instance = null;
19
20
	/**
21
	 * Holds the modals to be outputted
22
	 *
23
	 * @var array
24
	 */
25
	public $modals = array();
26
27
	/**
28
	 * Constructor
29
	 */
30
	public function __construct() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
31
		add_action( 'wp_footer', array( $this, 'output_modals' ) );
32
	}
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...
33
34
	/**
35
	 * Return an instance of this class.
36
	 *
37
	 * @since 1.0.0
38
	 *
39
	 * @return    object \lsx_health_plan\classes\Endpoints()    A single instance of this class.
40
	 */
41
	public static function get_instance() {
42
		// If the single instance hasn't been set, set it now.
43
		if ( null === self::$instance ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
44
			self::$instance = new self();
45
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
46
		return self::$instance;
47
	}
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...
48
49
	/**
50
	 * Registers a modal to be outputted
51
	 *
52
	 * @param array $modal
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Expected 2 spaces after parameter type; 1 found
Loading history...
53
	 * @param string $index
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
54
	 * @return void
55
	 */
56
	public function register_modal( $modal = array(), $index = '' ) {
57
		if ( '' !== $index && ! empty( $modal ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
58
			$modal['id'] = $index;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 12 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...
59
			$this->modals[ $index ] = $modal;
60
		}
61
	}
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...
62
63
	/**
64
	 * Registers the rewrites.
65
	 */
66
	public function output_modals() {
67
		if ( ! empty( $this->modals ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
68
			wp_enqueue_script( 'lsx-health-plan-modals', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-modals.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true );
69
70
			foreach ( $this->modals as $index => $modal ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
71
				\lsx_health_plan\functions\output_modal( $modal );
72
			}
73
		}
74
	}
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...
75
}
76