1 | <?php |
||
16 | class WC_Logger { |
||
17 | |||
18 | /** |
||
19 | * Stores open file _handles. |
||
20 | * |
||
21 | * @var array |
||
22 | * @access private |
||
23 | */ |
||
24 | private $_handles; |
||
25 | |||
26 | /** |
||
27 | * Constructor for the logger. |
||
28 | */ |
||
29 | public function __construct() { |
||
32 | |||
33 | /** |
||
34 | * Destructor. |
||
35 | */ |
||
36 | public function __destruct() { |
||
43 | |||
44 | /** |
||
45 | * Open log file for writing. |
||
46 | * |
||
47 | * @param string $handle |
||
48 | * @param string $mode |
||
49 | * @return bool success |
||
50 | */ |
||
51 | protected function open( $handle, $mode = 'a' ) { |
||
62 | |||
63 | /** |
||
64 | * Close a handle. |
||
65 | * |
||
66 | * @param string $handle |
||
67 | * @return bool success |
||
68 | */ |
||
69 | protected function close( $handle ) { |
||
79 | |||
80 | /** |
||
81 | * Add a log entry to chosen file. |
||
82 | * |
||
83 | * @param string $handle |
||
84 | * @param string $message |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | public function add( $handle, $message ) { |
||
100 | |||
101 | /** |
||
102 | * Clear entries from chosen file. |
||
103 | * |
||
104 | * @param string $handle |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | public function clear( $handle ) { |
||
126 | |||
127 | } |
||
128 |
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.