private function convertResponseField()

in util/ActionTest.php [520:543]


    private function convertResponseField(string $field): string
    {
        $output = '$response';
        if ($field === '$body' || $field === '') {
            return $output;
        }
        // if the field starts with a .$variable remove the first dot
        if (substr($field, 0, 2) === '.$') {
            $field = substr($field, 1);
        }
        # Remove \. from $field
        $field = str_replace ('\.', chr(200), $field);
        $parts = explode('.', $field);
        foreach ($parts as $part) {
            # Replace \. in $part
            $part = str_replace (chr(200), '.', $part);
            if (is_int($part)) {
                $output .= sprintf("[%d]", $part);
            } else {
                $output .= sprintf("[\"%s\"]", $part);
            }
        }
        return $output;
    }