Evaluate the rule based on the context

@return null if no rewrite took place
552864
public CharSequence evaluate(CharSequence url, Resolver resolver) {
        Pattern pattern = this.pattern.get();
        if (pattern == null) {
            // Parse the pattern
            int flags = 0;
            if (isNocase()) {
                flags |= Pattern.CASE_INSENSITIVE;
            }
            pattern = Pattern.compile(patternString, flags);
            this.pattern.set(pattern);
        }
        Matcher matcher = pattern.matcher(url);
        if (!matcher.matches()) {
            // Evaluation done
            return null;
        }
        // Evaluate conditions
        boolean done = false;
        boolean rewrite = true;
        Matcher lastMatcher = null;
        int pos = 0;
        while (!done) {
            if (pos < conditions.length) {
                rewrite = conditions[pos].evaluate(matcher, lastMatcher, resolver);
                if (rewrite) {
                    Matcher lastMatcher2 = conditions[pos].getMatcher();
                    if (lastMatcher2 != null) {
                        lastMatcher = lastMatcher2;
                    }
                    while (pos < conditions.length && conditions[pos].isOrnext()) {
                        pos++;
                    }
                } else if (!conditions[pos].isOrnext()) {
                    done = true;
                }
                pos++;
            } else {
                done = true;
            }
        }
        // Use the substitution to rewrite the url
        if (rewrite) {
            if (isEnv()) {
                for (int i = 0; i < envSubstitution.size(); i++) {
                    envResult.get(i).set(envSubstitution.get(i).evaluate(matcher, lastMatcher, resolver));
                }
            }
            if (isCookie()) {
                cookieResult.set(cookieSubstitution.evaluate(matcher, lastMatcher, resolver));
            }
            if (substitution != null) {
                return substitution.evaluate(matcher, lastMatcher, resolver);
            } else {
                return url;
            }
        } else {
            return null;
        }
    }
1106102
public function evaluate()
    {
        if ($this->url === null) {
            throw new BuildException("No url specified in http condition");
        }

        if (!filter_var($this->url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {
            $this->log(
                "Possible malformed URL: " . $this->url,
                $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN
            );
        }

        $this->log("Checking for " . $this->url, Project::MSG_VERBOSE);

        $handle = curl_init($this->url);
        curl_setopt($handle, CURLOPT_NOBODY, true);
        curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $this->requestMethod);
        curl_setopt($handle, CURLOPT_FOLLOWLOCATION, $this->followRedirects);

        if (!curl_exec($handle)) {
            $this->log(
                "No response received from URL: " . $this->url,
                $this->quiet ? Project::MSG_VERBOSE : Project::MSG_ERR
            );

            return false;
        }

        $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
        curl_close($handle);

        $this->log("Result code for " . $this->url . " was " . $httpCode, Project::MSG_VERBOSE);

        $result = false;
        if ($httpCode > 0 && $httpCode < $this->errorsBeginAt) {
            $result = true;
        }

        return $result;
    }
797120
function evaluate() {
        if ($this->_nfx == false) {
            return false;
        }
        $res = $this->_em->pfx($this->_nfx);
        if ($res === false) {
            $this->_error = $this->_em->last_error;
            return false;
        } else {
            $this->_error = false;
            return $res;
        }
    }
862339
public function evaluate()
    {
        if ($this->stack->hasMessage() && $this->isEnabled()) {
            $this->getRuntime()->setEnableContentCache(false);
            return $this->stack->dump();
        }
        return $this->fusionValue('value');
    }
704738
public function evaluate()
    {
        $currentContext = $this->runtime->getCurrentContext();
        $this->pluginViewNode = $currentContext['node'];
        /** @var $parentResponse Response */
        $parentResponse = $this->runtime->getControllerContext()->getResponse();
        $pluginResponse = new ActionResponse($parentResponse);

        $pluginRequest = $this->buildPluginRequest();
        if ($pluginRequest->getControllerObjectName() === '') {
            $message = 'Master View not selected';
            if ($this->pluginViewNode->getProperty('plugin')) {
                $message = 'Plugin View not selected';
            }
            if ($this->pluginViewNode->getProperty('view')) {
                $message ='Master View or Plugin View not found';
            }
            return $this->pluginViewNode->getContext()->getWorkspaceName() !== 'live' || $this->objectManager->getContext()->isDevelopment() ? '<p>' . $message . '</p>' : '<!-- ' . $message . '-->';
        }
        $this->dispatcher->dispatch($pluginRequest, $pluginResponse);
        return $pluginResponse->getContent();
    }
654786
public function evaluate(Rule $rule)
    {
        if (is_array($rule->getLeft()) && is_array($rule->getRight())) {
            $intersect = array_intersect($rule->getLeft(), $rule->getRight());
            if (array_diff($rule->getRight(), $intersect))
                return false;
            return true;
        } elseif (is_array($rule->getLeft()) && !is_array($rule->getRight())) {
            return in_array($rule->getRight(), $rule->getLeft());
        } elseif (!is_array($rule->getLeft()) && is_array($rule->getRight())) {
            return in_array($rule->getLeft(), $rule->getRight());
        }

        return false;
    }
1301251
private function evaluateAll()
    {
        if($this->isEvaluated) {
            return;
        }
        foreach($this->rules as $key => $rule) {
            $this->evaluateAndGet($key);
        }
    }
1317077
public function getRule()
    {
        $returnValue = (string) '';

        
        
        // Get the if / elseif conditions and the associated actions
        foreach ($this->responseIfs as $responseElseIf){
            $returnValue .= (empty($returnValue) ? '' : ' else ').$responseElseIf->getRule();
        }
        
        // Get the else actions
        if (!empty($this->responseElse)){
            $returnValue .= 'else {';
            foreach ($this->responseElse as $actions){
                $returnValue .= $actions->getRule();
            }
            $returnValue .= '}';
        }
        
        

        return (string) $returnValue;
    }
659090
public function evaluate( Context $context ) {
		/**
		 * Extracts variables.
		 *
		 * @var \Ruler\Variable $left
		 * @var \Ruler\Variable $right
		 */
		list( $left, $right ) = $this->getOperands();

		$left  = $left->prepareValue( $context )->getValue();
		$right = $right->prepareValue( $context )->getValue();

		if ( 2 !== count( $right ) ) {
			return false;
		}

		// Make sure we have a valid range.
		if ( $right[0] > $right[1] ) {
			$temp     = $right[0];
			$right[0] = $right[1];
			$right[1] = $temp;
		}

		return ( $left >= $right[0] && $left <= $right[1] );
	}
1293831
public function evaluate()
    {
        $this->validate();
        $actual = $this->getVersion();
        if (null != $this->atLeast) {
            return version_compare($actual, $this->atLeast, '>=');
        }

        if (null != $this->exactly) {
            return version_compare($actual, $this->exactly, '=');
        }

        return false;
    }
415921
protected function evalExpression()
    {
        $this->log("Evaluating PHP expression: " . $this->expression, $this->logLevel);
        if (!StringHelper::endsWith(';', trim($this->expression))) {
            $this->expression .= ';';
        }

        if ($this->returnProperty !== null) {
            $retval = null;
            eval('$retval = ' . $this->expression);
            $this->project->setProperty($this->returnProperty, $retval);
        } else {
            eval($this->expression);
        }
    }
91908
public function getRule(){
        $returnValue = (string) '';


        if($this->uri == self::MATCH_CORRECT){
            $returnValue = taoQTI_models_classes_Matching_Matching::MATCH_CORRECT;
        }else if($this->uri == self::MAP_RESPONSE){
            $returnValue = taoQTI_models_classes_Matching_Matching::MAP_RESPONSE;
        }else if($this->uri == self::MAP_RESPONSE_POINT){
            $returnValue = taoQTI_models_classes_Matching_Matching::MAP_RESPONSE_POINT;
        }



        return (string) $returnValue;
    }
675554
protected function getValueFromContext($rule, $context)
    {
        // Fields are only nested one level deep and flattened thereafter.
        $parts = explode('.', $rule->field);
        $key   = array_shift($parts);
        if (isset($context[$key]) && count($parts)) {
            $context = $context[$key];
            $key     = implode('.', $parts);
        } else {
            $key = $rule->field;
        }

        return isset($context[$key]) ? $context[$key] : false;
    }
699965
public function evaluateRules()
    {
        foreach ($this->rules as $rule => $condition) {
            $this->rules[$rule] = $this->conditions->is($rule, $condition);
        }

        return $this->rules;
    }
768764
protected static function evaluateLogical(ContextInterface $context, array $serializedLogical = null): bool
    {
        if ($serializedLogical === null) {
            return true;
        }

        $evaluation = call_user_func($serializedLogical, $context);
        $result     = $evaluation === true;

        return $result;
    }
624667
public function execute()
    {
        $result = filter_var($this->value, FILTER_VALIDATE_URL);
        
        if ($result === false) {
            $this->msg = 'validator.rule.url';
        }
    }
305872
public function find($re, $filter = null) {
        $result = null;
        $this->each(function($context) use ($re, $filter, &$result) {
            $r = $context->find($re, $filter);
            if (!$r->isEmpty()) {
                $result = $r;
                return false;
            }
        });

        return $result?:Context::getEmptyContext();
    }