return $this from add* methods to allow method chaining
authorJames Pepin <james@jamespepin.com>
Sun, 27 Sep 2009 01:29:14 +0000 (21:29 -0400)
committerJames Pepin <james@jamespepin.com>
Sun, 27 Sep 2009 01:29:14 +0000 (21:29 -0400)
framework/Log/lib/Horde/Log/Filter/Constraint.php

index 06fb66f..7a645f0 100644 (file)
@@ -29,6 +29,8 @@ class Horde_Log_Filter_Constraint implements Horde_Log_Filter_Interface
      *
      * @param string $field  The field to apply the constraint to
      * @param Horde_Constraint $constraint  The constraint to apply
+     *
+     * @return Horde_Log_Filter_Constraint A reference to $this to allow method chaining
      */
     public function addConstraint($field, Horde_Constraint $constraint)
     {
@@ -37,6 +39,7 @@ class Horde_Log_Filter_Constraint implements Horde_Log_Filter_Interface
         } else {
             $this->_constraints[$field] = $constraint;
         }
+        return $this;
     }
 
     /**
@@ -47,11 +50,12 @@ class Horde_Log_Filter_Constraint implements Horde_Log_Filter_Interface
      *
      * @param string $field The name of the field that should be part of the event
      * @param string $regex The regular expression to filter by
+     * @return Horde_Log_Filter_Constraint A reference to $this to allow method chaining
      */
     public function addRegex($field, $regex)
     {
         $constraint = new Horde_Constraint_PregMatch($regex);
-        $this->addConstraint($field, $constraint);
+        return $this->addConstraint($field, $constraint);
     }
 
     /**
@@ -60,15 +64,18 @@ class Horde_Log_Filter_Constraint implements Horde_Log_Filter_Interface
      * If the field does not exist on the event, then it is filtered.
      *
      * @param string $field The name of the field that should be part of the event
+     * @return Horde_Log_Filter_Constraint A reference to $this to allow method chaining
      */
     public function addRequiredField($field)
     {
         $notNull = new Horde_Constraint_Not(new Horde_Constraint_Null());
-        $this->addConstraint($field, $notNull);
+        return $this->addConstraint($field, $notNull);
     }
 
     /**
      * Adds all arguments passed as required fields
+     *
+     * @return Horde_Log_Filter_Constraint A reference to $this to allow method chaining
      */
     public function addRequiredFields()
     {
@@ -76,6 +83,7 @@ class Horde_Log_Filter_Constraint implements Horde_Log_Filter_Interface
         foreach ($fields as $f) {
             $this->addRequiredField($f);
         }
+        return $this;
     }
 
     /**