'array', 'items' => array( 'type' => 'string' ), ); } /** * Gets the default value for a newly created condition of this type. * * @return mixed */ public function default_value() { return array(); } /** * Evaluates the condition against the given context. * * @param Context $context Request context value object. * @param string $operator Operator identifier. * @param mixed $value Configured value. * @return bool */ public function evaluate( Context $context, string $operator, $value ): bool { $needles = $this->string_list( $value ); $contains = false; // The request URL is percent-encoded; also match a typed "café" or "a b". $decoded = rawurldecode( $context->url ); foreach ( $needles as $needle ) { if ( '' !== $needle && ( false !== strpos( $context->url, $needle ) || false !== strpos( $decoded, $needle ) ) ) { $contains = true; break; } } return 'not_contains' === $operator ? ! $contains : $contains; } }