original_string: public function addCondition($field, $operator = UNDEFINED, $value = UNDEFINED)
      {
          if (!$this->controller) {
              throw $this->exception('Controller for this model is not set', 'NotImplemented');
          }
          if (!@$this->controller->supportConditions) {
              throw $this->exception('The controller doesn\'t support conditions', 'NotImplemented')
                  ->addMoreInfo('controller', $this->controller);
          }
          if (is_array($field)) {
              foreach ($field as $value) {
                  $this->addCondition($value[0], $value[1], count($value) === 2 ? UNDEFINED : $value[2]);
              }
  
              return $this;
          } elseif (($operator === UNDEFINED) && (!is_object($field))) { // controller can handle objects
              throw $this->exception('You must define the second argument');
          }
          if ($value === UNDEFINED) {
              $value = $operator;
              $operator = '=';
          }
          $supportOperators = $this->controller->supportOperators;
          if ($supportOperators !== 'all' && (is_null($supportOperators) || (!isset($supportOperators[$operator])))) {
              throw $this->exception('Unsupport operator', 'NotImplemented')
                  ->addMoreInfo('operator', $operator);
          }
  
          $this->conditions[] = array($field, $operator, $value);
  
          return $this;
      }
code: public function addCondition($field, $operator = UNDEFINED, $value = UNDEFINED)
      {
          if (!$this->controller) {
              throw $this->exception('Controller for this model is not set', 'NotImplemented');
          }
          if (!@$this->controller->supportConditions) {
              throw $this->exception('The controller doesn\'t support conditions', 'NotImplemented')
                  ->addMoreInfo('controller', $this->controller);
          }
          if (is_array($field)) {
              foreach ($field as $value) {
                  $this->addCondition($value[0], $value[1], count($value) === 2 ? UNDEFINED : $value[2]);
              }
  
              return $this;
          } elseif (($operator === UNDEFINED) && (!is_object($field))) { // controller can handle objects
              throw $this->exception('You must define the second argument');
          }
          if ($value === UNDEFINED) {
              $value = $operator;
              $operator = '=';
          }
          $supportOperators = $this->controller->supportOperators;
          if ($supportOperators !== 'all' && (is_null($supportOperators) || (!isset($supportOperators[$operator])))) {
              throw $this->exception('Unsupport operator', 'NotImplemented')
                  ->addMoreInfo('operator', $operator);
          }
  
          $this->conditions[] = array($field, $operator, $value);
  
          return $this;
      }
code_tokens: public function addCondition ( $ field , $ operator = UNDEFINED , $ value = UNDEFINED ) { if ( ! $ this -> controller ) { throw $ this -> exception ( 'Controller for this model is not set' , 'NotImplemented' ) ; } if ( ! @ $ this -> controller -> supportConditions ) { throw $ this -> exception ( 'The controller doesn\'t support conditions' , 'NotImplemented' ) -> addMoreInfo ( 'controller' , $ this -> controller ) ; } if ( is_array ( $ field ) ) { foreach ( $ field as $ value ) { $ this -> addCondition ( $ value [ 0 ] , $ value [ 1 ] , count ( $ value ) === 2 ? UNDEFINED : $ value [ 2 ] ) ; } return $ this ; } elseif ( ( $ operator === UNDEFINED ) && ( ! is_object ( $ field ) ) ) { // controller can handle objects throw $ this -> exception ( 'You must define the second argument' ) ; } if ( $ value === UNDEFINED ) { $ value = $ operator ; $ operator = '=' ; } $ supportOperators = $ this -> controller -> supportOperators ; if ( $ supportOperators !== 'all' && ( is_null ( $ supportOperators ) || ( ! isset ( $ supportOperators [ $ operator ] ) ) ) ) { throw $ this -> exception ( 'Unsupport operator' , 'NotImplemented' ) -> addMoreInfo ( 'operator' , $ operator ) ; } $ this -> conditions [ ] = array ( $ field , $ operator , $ value ) ; return $ this ; }
docstring: Adds a new condition for this model
docstring_tokens: Adds a new condition for this model