src/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilter.php
private function addEqualityMatchStrategy(string $strategy, string $field, $value, bool $caseSensitive, ClassMetadata $metadata)
    {
        $type = $metadata->getTypeOfField($field);

        switch ($strategy) {
            case MongoDbType::STRING !== $type:
                return MongoDbType::getType($type)->convertToDatabaseValue($value);
            case null:
            case self::STRATEGY_EXACT:
                return $caseSensitive ? $value : new Regex("^$value$", 'i');
            case self::STRATEGY_PARTIAL:
                return new Regex($value, $caseSensitive ? '' : 'i');
            case self::STRATEGY_START:
                return new Regex("^$value", $caseSensitive ? '' : 'i');
            case self::STRATEGY_END:
                return new Regex("$value$", $caseSensitive ? '' : 'i');
            case self::STRATEGY_WORD_START:
                return new Regex("(^$value.*|.*\s$value.*)", $caseSensitive ? '' : 'i');
            default:
                throw new InvalidArgumentException(sprintf('strategy %s does not exist.', $strategy));
        }
    }
private function addEqualityMatchStrategy(string $strategy, string $field, $value, bool $caseSensitive, ClassMetadata $metadata)
    {
        $type = $metadata->getTypeOfField($field);

        switch ($strategy) {
            case MongoDbType::STRING !== $type:
                return MongoDbType::getType($type)->convertToDatabaseValue($value);
            case null:
            case self::STRATEGY_EXACT:
                return $caseSensitive ? $value : new Regex("^$value$", 'i');
            case self::STRATEGY_PARTIAL:
                return new Regex($value, $caseSensitive ? '' : 'i');
            case self::STRATEGY_START:
                return new Regex("^$value", $caseSensitive ? '' : 'i');
            case self::STRATEGY_END:
                return new Regex("$value$", $caseSensitive ? '' : 'i');
            case self::STRATEGY_WORD_START:
                return new Regex("(^$value.*|.*\s$value.*)", $caseSensitive ? '' : 'i');
            default:
                throw new InvalidArgumentException(sprintf('strategy %s does not exist.', $strategy));
        }
    }
private function addEqualityMatchStrategy ( string $ strategy , string $ field , $ value , bool $ caseSensitive , ClassMetadata $ metadata ) { $ type = $ metadata -> getTypeOfField ( $ field ) ; switch ( $ strategy ) { case MongoDbType :: STRING !== $ type : return MongoDbType :: getType ( $ type ) -> convertToDatabaseValue ( $ value ) ; case null : case self :: STRATEGY_EXACT : return $ caseSensitive ? $ value : new Regex ( "^$value$" , 'i' ) ; case self :: STRATEGY_PARTIAL : return new Regex ( $ value , $ caseSensitive ? '' : 'i' ) ; case self :: STRATEGY_START : return new Regex ( "^$value" , $ caseSensitive ? '' : 'i' ) ; case self :: STRATEGY_END : return new Regex ( "$value$" , $ caseSensitive ? '' : 'i' ) ; case self :: STRATEGY_WORD_START : return new Regex ( "(^$value.*|.*\s$value.*)" , $ caseSensitive ? '' : 'i' ) ; default : throw new InvalidArgumentException ( sprintf ( 'strategy %s does not exist.' , $ strategy ) ) ; } }
Add equality match stage according to the strategy.

@throws InvalidArgumentException If strategy does not exist

@return Regex|string
Add equality match stage according to the strategy .