Completed
Push — master ( 5d13f2...054e7e )
by Dwain
05:00
created

Sensei_Notices::print_notices()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 13
rs 9.4285
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4
/**
5
 * Sensei Notices Class
6
 *
7
 * All functionality pertaining to displaying of various notices accross.
8
 *
9
 * @package Core
10
 * @author Automattic
11
 *
12
 * @since 1.6.3
13
 */
14
15
class Sensei_Notices{
16
17
	/**
18
	*  @var $notices
19
	*/
20
	protected $notices;
21
22
	/**
23
	*  constructor 
24
 	*/
25
	public function __construct(){
26
		//initialize the notices variable
27
		$this->notices = array();
28
	}
29
30
	/**
31
	*  Add a notice to the array of notices for display at a later stage.
32
	* 
33
	*
34
	* 
35
	* @param string $message 
36
	* @param string $type defaults to alert options( alert, tick , download , info   )
0 ignored issues
show
Bug introduced by
There is no parameter named $message. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
37
	*
38
	* @return void
39
	*/
40
41
	public function add_notice( $content ,  $type = 'alert'   ){
42
		// append the new notice
43
		$this->notices[] = array('content' => $content , 'type'=> $type );
44
	} // end add_notice()
45
46
	/**
47
	*  Output all notices added 
48
	* 
49
	* @param string $message 
50
	* @param string $type
0 ignored issues
show
Bug introduced by
There is no parameter named $message. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
51
	*
0 ignored issues
show
Bug introduced by
There is no parameter named $type. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
52
	* @return void
53
	*/
54
55
	public function print_notices(){
56
		if(  count( $this->notices ) > 0  ){
57
			foreach ($this->notices  as  $notice) {
58
59
				$classes = 'sensei-message '. $notice['type'];
60
				$html = '<div class="'. $classes . '">'. $notice['content'] . '</div>';
61
62
				echo $html; 
63
			}
64
			// empty the notice queue to avoid reprinting the same notices
65
			$this->clear_notices();
66
		}
67
	} // end print_notice()
68
69
	/**
70
	*  Clear all notices  
71
	* 
72
	* @return void
73
	*/
74
75
	public function clear_notices(){
76
		// assign an empty array to clear all existing notices
77
		$this->notices = array();
78
	} // end clear_notices()
79
80
} // end Woothemes_Sensei_Notices
81
82
/**
83
 * Class Woothemes_Sensei_Notices
84
 * @ignore only for backward compatibility
85
 * @since 1.9.0
86
 */
87
class Woothemes_Sensei_Notices extends Sensei_Notices{}
88