Ingo_Rule_User::getTestInfo PHP Method

getTestInfo() public method

Returns information on a given test string.
public getTestInfo ( $test ) : object
return object Object with the following values: - label: (string) The label for this action. - type: (string) Either 'int', 'none', or 'text'.
    public function getTestInfo($test)
    {
        /* Mapping of gettext strings -> labels. */
        $labels = array('contains' => _("Contains"), 'not contain' => _("Doesn't contain"), 'is' => _("Is"), 'not is' => _("Isn't"), 'begins with' => _("Begins with"), 'not begins with' => _("Doesn't begin with"), 'ends with' => _("Ends with"), 'not ends with' => _("Doesn't end with"), 'exists' => _("Exists"), 'not exist' => _("Doesn't exist"), 'regex' => _("Regular expression"), 'not regex' => _("Doesn't match regular expression"), 'matches' => _("Matches (with placeholders)"), 'not matches' => _("Doesn't match (with placeholders)"), 'less than' => _("Less than"), 'less than or equal to' => _("Less than or equal to"), 'greater than' => _("Greater than"), 'greater than or equal to' => _("Greater than or equal to"), 'equal' => _("Equal to"), 'not equal' => _("Not equal to"));
        /* The type of tests available. */
        $types = array('int' => array('less than', 'less than or equal to', 'greater than', 'greater than or equal to', 'equal', 'not equal'), 'none' => array('exists', 'not exist'), 'text' => array('contains', 'not contain', 'is', 'not is', 'begins with', 'not begins with', 'ends with', 'not ends with', 'regex', 'not regex', 'matches', 'not matches'));
        /* Create the information object. */
        $ob = new stdClass();
        $ob->label = $labels[$test];
        foreach ($types as $key => $val) {
            if (in_array($test, $val)) {
                $ob->type = $key;
                break;
            }
        }
        return $ob;
    }