Code Duplication    Length = 21-25 lines in 2 locations

src/Encoder/UrlEncodedTypeEncoder.php 1 location

@@ 66-90 (lines=25) @@
63
     *
64
     * @throws \InvalidArgumentException
65
     */
66
    private function getValueAsString($value): string
67
    {
68
        if (is_string($value)) {
69
            return $value;
70
        }
71
72
        if (is_bool($value)) {
73
            return $value ? 'true' : 'false';
74
        }
75
76
        if (is_float($value)) {
77
            $value = (string) $value;
78
            if (false === strpos($value, '.')) {
79
                $value .= '.0';
80
            }
81
82
            return $value;
83
        }
84
85
        if (is_int($value)) {
86
            return (string) $value;
87
        }
88
89
        throw new \InvalidArgumentException(sprintf('Unsupported data type: %s', gettype($value)));
90
    }
91
}
92

src/Encoder/XmlTypeEncoder.php 1 location

@@ 189-209 (lines=21) @@
186
     *
187
     * @throws \InvalidArgumentException
188
     */
189
    private function getValueAsString($value): string
190
    {
191
        if (is_bool($value)) {
192
            return $value ? 'true' : 'false';
193
        }
194
195
        if (is_float($value)) {
196
            $value = (string) $value;
197
            if (false === strpos($value, '.')) {
198
                $value .= '.0';
199
            }
200
201
            return $value;
202
        }
203
204
        if (is_int($value)) {
205
            return (string) $value;
206
        }
207
208
        throw new \InvalidArgumentException(sprintf('Unsupported data type: %s', gettype($value)));
209
    }
210
211
    /**
212
     * @param bool|float|int|string $value