whitelist = $whitelist; return $this; } /** * Check if item exists in the whitelist. * * @param string $item string to check. * @param array $whitelist optional with all valid options, default is null. * * @return boolean true if item is in whitelist, else false. */ public function check($item, $whitelist = null) { if ($whitelist !== null) { $this->set($whitelist); } if (empty($item) or empty($this->whitelist)) { return false; } foreach ($this->whitelist as $regexp) { if (preg_match("#$regexp#", $item)) { return true; } } return false; } }