3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Log\Filter
;
13 use Zend\Log\Exception
;
15 class SuppressFilter
implements FilterInterface
20 protected $accept = true;
23 * This is a simple boolean filter.
25 * @param int|array|Traversable $suppress
26 * @throws Exception\InvalidArgumentException
28 public function __construct($suppress = false)
30 if ($suppress instanceof Traversable
) {
31 $suppress = iterator_to_array($suppress);
33 if (is_array($suppress)) {
34 $suppress = isset($suppress['suppress']) ?
$suppress['suppress'] : false;
36 if (!is_bool($suppress)) {
37 throw new Exception\
InvalidArgumentException(sprintf(
38 'Suppress must be an boolean; received "%s"', gettype($suppress)
42 $this->suppress($suppress);
46 * This is a simple boolean filter.
48 * Call suppress(true) to suppress all log events.
49 * Call suppress(false) to accept all log events.
51 * @param bool $suppress Should all log events be suppressed?
54 public function suppress($suppress)
56 $this->accept
= ! (bool) $suppress;
60 * Returns TRUE to accept the message, FALSE to block it.
62 * @param array $event event data
63 * @return bool accepted?
65 public function filter(array $event)