| 1 | <?php |
||
| 6 | class CWhitelist |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * Array to contain the whitelist options. |
||
| 10 | */ |
||
| 11 | private $whitelist = array(); |
||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | /** |
||
| 16 | * Set the whitelist from an array of strings, each item in the |
||
| 17 | * whitelist should be a regexp without the surrounding / or #. |
||
| 18 | * |
||
| 19 | * @param array $whitelist with all valid options, |
||
| 20 | * default is to clear the whitelist. |
||
| 21 | * |
||
| 22 | * @return $this |
||
| 23 | */ |
||
| 24 | 6 | public function set($whitelist = array()) |
|
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | /** |
||
| 37 | * Check if item exists in the whitelist. |
||
| 38 | * |
||
| 39 | * @param string $item string to check. |
||
| 40 | * @param array $whitelist optional with all valid options, default is null. |
||
| 41 | * |
||
| 42 | * @return boolean true if item is in whitelist, else false. |
||
| 43 | */ |
||
| 44 | 5 | public function check($item, $whitelist = null) |
|
| 62 | } |
||
| 63 |