Gajus\Dora\Input::stringifyAttributes PHP Method

stringifyAttributes() private method

Attribute string will vary depending on the input type. [value] is excluded intentionally because of the inconsistent implementation between different input types.
private stringifyAttributes ( )
    private function stringifyAttributes()
    {
        $attributes = $this->attributes;
        $attributes_string = '';
        switch ($this->attributes['type']) {
            case 'checkbox':
            case 'radio':
                $value = $this->getValue();
                if ($this->attributes['value'] == $value || is_array($value) && in_array($this->attributes['value'], $value)) {
                    $attributes['checked'] = 'checked';
                }
                break;
            case 'textarea':
            case 'select':
                unset($attributes['type']);
                break;
        }
        if (!in_array($this->attributes['type'], ['checkbox', 'radio'])) {
            unset($attributes['value']);
        }
        ksort($attributes);
        // To make the unit testing simpler.
        #if (strpos(strrev($attributes['name']), '][') === 0) {
        #    $attributes['name'] = substr_replace($attributes['name'], '[' . $this->index . ']', -2);
        #}
        foreach ($attributes as $k => $v) {
            $attributes_string .= ' ' . $k . '="' . $v . '"';
        }
        return trim($attributes_string);
    }