/** * Remove condition. * * @param Condition $condition * * @internal param Condition $conditions */ public function removeCondition(Condition $condition) { $this->entity->removeCondition($condition->getEntity()); }
/** * Parses and returns the value of a condition. * * @param Condition $condition * * @return mixed * * @throws ConditionTypeMismatchException */ protected function getValue(Condition $condition) { $value = $condition->getValue(); $type = $condition->getType(); switch ($type) { case DataTypes::UNDEFINED_TYPE: case DataTypes::STRING_TYPE: case DataTypes::TAGS_TYPE: case DataTypes::AUTO_COMPLETE_TYPE: return $value; case DataTypes::NUMBER_TYPE: if (is_numeric($value)) { return floatval($value); } throw new ConditionTypeMismatchException($condition->getId(), $value, $type); case DataTypes::BOOLEAN_TYPE: return $this->getBoolean($value); case DataTypes::DATETIME_TYPE: try { return new \DateTime($value); } catch (\Exception $ex) { throw new ConditionTypeMismatchException($condition->getId(), $value, $type); } default: throw new ConditionTypeMismatchException($condition->getId(), $value, $type); } }