1 | <?php |
||
24 | class Censor |
||
25 | { |
||
26 | const WHOLE_WORD = 'censorWholeWord'; |
||
27 | const IGNORE_CASE = 'censorIgnoreCase'; |
||
28 | const SHOW_NO_CENSORED = 'show_no_censored'; |
||
29 | const ALLOW_NO_CENSORED = 'allow_no_censored'; |
||
30 | |||
31 | protected $vulgar = array(); |
||
32 | protected $proper = array(); |
||
33 | protected $options = array( |
||
34 | self::WHOLE_WORD => false, |
||
35 | self::IGNORE_CASE => false, |
||
36 | self::SHOW_NO_CENSORED => false, |
||
37 | self::ALLOW_NO_CENSORED => false, |
||
38 | ); |
||
39 | |||
40 | /** |
||
41 | * Censor constructor. |
||
42 | * @param array $vulgar |
||
43 | * @param array $proper |
||
44 | * @param array $options |
||
45 | */ |
||
46 | 1 | public function __construct(array $vulgar, array $proper, array $options = array()) |
|
56 | |||
57 | /** |
||
58 | * @param array $options |
||
59 | */ |
||
60 | 1 | protected function setOptions(array $options) |
|
64 | |||
65 | /** |
||
66 | * @param array $vulgar |
||
67 | * @param array $proper |
||
68 | */ |
||
69 | 1 | protected function setVulgarProper(array $vulgar, array $proper) |
|
84 | |||
85 | /** |
||
86 | * Censor a string |
||
87 | * |
||
88 | * @param string $text |
||
89 | * @param bool $force |
||
90 | * @return string |
||
91 | */ |
||
92 | 2 | public function censor($text, $force = false) |
|
110 | |||
111 | /** |
||
112 | * Check if we should be censoring. |
||
113 | * |
||
114 | * @todo replace with inline checking at some point |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 2 | public function doCensor() |
|
124 | } |
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.