1 | <?php |
||
14 | class Sensei_Notices{ |
||
15 | |||
16 | /** |
||
17 | * @var $notices |
||
18 | */ |
||
19 | protected $notices; |
||
20 | |||
21 | /** |
||
22 | * @var boolean $has_printed |
||
23 | */ |
||
24 | protected $has_printed; |
||
25 | |||
26 | /** |
||
27 | * constructor |
||
28 | */ |
||
29 | public function __construct(){ |
||
34 | |||
35 | /** |
||
36 | * Add a notice to the array of notices for display at a later stage. |
||
37 | * |
||
38 | * |
||
39 | * @param string $content |
||
40 | * @param string $type defaults to alert options( alert, tick , download , info ) |
||
41 | * |
||
42 | * @return void |
||
43 | */ |
||
44 | |||
45 | public function add_notice( $content , $type = 'alert' ){ |
||
55 | |||
56 | /** |
||
57 | * Output all notices added |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | |||
62 | public function maybe_print_notices(){ |
||
80 | |||
81 | /** |
||
82 | * Clear all notices |
||
83 | * |
||
84 | * @return void |
||
85 | */ |
||
86 | public function clear_notices(){ |
||
90 | |||
91 | } // end Woothemes_Sensei_Notices |
||
92 | |||
99 |
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.