Ejemplo n.º 1
0
 /**
  * @see \PHPLog\FilterAbstract::decide()
  */
 public function decide(Event $event)
 {
     //if level max is not a Level.
     if (!$this->levelMax instanceof Level) {
         return FilterAbstract::NEUTRAL;
     }
     //if level min is not a level.
     if (!$this->levelMin instanceof Level) {
         return FilterAbstract::NEUTRAL;
     }
     //if level min is equal to all or is greater than max.
     if ($this->levelMin->equals(Level::all()) || $this->levelMin->isGreaterOrEqualTo($this->levelMax)) {
         return FilterAbstract::NEUTRAL;
     }
     //if max if equal to off.
     if ($this->levelMax->equals(Level::off())) {
         return FilterAbstract::NEUTRAL;
     }
     //check that the event level is between the range.
     $lmi = $this->levelMin->getIntLevel();
     $lma = $this->levelMax->getIntLevel();
     $e = $event->getLevel()->getIntLevel();
     if ($e >= $lmi && $e <= $lma) {
         //in the range.
         return $this->acceptOnMatch ? FilterAbstract::ACCEPT : FilterAbstract::DENY;
     }
     return FilterAbstract::NEUTRAL;
 }