Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Log / Filter / Priority.php
blob726d20e9bbc1ee893f6064cee4ac98ccf11e38b0
1 <?php
2 /**
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
8 */
10 namespace Zend\Log\Filter;
12 use Traversable;
13 use Zend\Log\Exception;
15 class Priority implements FilterInterface
17 /**
18 * @var int
20 protected $priority;
22 /**
23 * @var string
25 protected $operator;
27 /**
28 * Filter logging by $priority. By default, it will accept any log
29 * event whose priority value is less than or equal to $priority.
31 * @param int|array|Traversable $priority Priority
32 * @param string $operator Comparison operator
33 * @return Priority
34 * @throws Exception\InvalidArgumentException
36 public function __construct($priority, $operator = null)
38 if ($priority instanceof Traversable) {
39 $priority = iterator_to_array($priority);
41 if (is_array($priority)) {
42 $operator = isset($priority['operator']) ? $priority['operator'] : null;
43 $priority = isset($priority['priority']) ? $priority['priority'] : null;
45 if (!is_int($priority)) {
46 throw new Exception\InvalidArgumentException(sprintf(
47 'Priority must be an integer; received "%s"',
48 gettype($priority)
49 ));
52 $this->priority = $priority;
53 $this->operator = $operator === null ? '<=' : $operator;
56 /**
57 * Returns TRUE to accept the message, FALSE to block it.
59 * @param array $event event data
60 * @return bool accepted?
62 public function filter(array $event)
64 return version_compare($event['priority'], $this->priority, $this->operator);