Code Duplication    Length = 10-11 lines in 3 locations

src/Html.php 3 locations

@@ 147-156 (lines=10) @@
144
     *
145
     * @return \Spatie\Html\Elements\Input
146
     */
147
    public function date($name = '', $value = null, $format = true)
148
    {
149
        $element = $this->input('date', $name, $value);
150
151
        if (! $format || empty($element->getAttribute('value'))) {
152
            return $element;
153
        }
154
155
        return $element->value($this->formatDateTime($element->getAttribute('value'), self::HTML_DATE_FORMAT));
156
    }
157
158
    /**
159
     * @param string|null $name
@@ 165-175 (lines=11) @@
162
     *
163
     * @return \Spatie\Html\Elements\Input
164
     */
165
    public function datetime($name = '', $value = null, $format = true)
166
    {
167
        $element = $this->input('datetime-local', $name, $value);
168
169
        if (! $format || empty($element->getAttribute('value'))) {
170
            return $element;
171
        }
172
173
        return $element->value($this->formatDateTime($element->getAttribute('value'),
174
            self::HTML_DATE_FORMAT."T".self::HTML_TIME_FORMAT));
175
    }
176
177
    /**
178
     * @param string|null $name
@@ 201-210 (lines=10) @@
198
     *
199
     * @return \Spatie\Html\Elements\Input
200
     */
201
    public function time($name = '', $value = null, $format = true)
202
    {
203
        $element = $this->input('time', $name, $value);
204
205
        if (! $format || empty($element->getAttribute('value'))) {
206
            return $element;
207
        }
208
209
        return $element->value($this->formatDateTime($element->getAttribute('value'), self::HTML_TIME_FORMAT));
210
    }
211
212
    /**
213
     * @param string $tag