internal/openapi/responder/serializer/rawSerializer.go   A
last analyzed

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 4
eloc 11
dl 0
loc 18
ccs 7
cts 7
cp 1
crap 4
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A serializer.*rawSerializer.Serialize 0 12 4
1
package serializer
2
3
import "fmt"
4
5
type rawSerializer struct{}
6
7
func (*rawSerializer) Serialize(data interface{}, format string) ([]byte, error) {
8 1
	if bytes, ok := data.([]byte); ok {
9 1
		return bytes, nil
10
	}
11 1
	if s, ok := data.(string); ok {
12 1
		return []byte(s), nil
13
	}
14 1
	if s, ok := data.(fmt.Stringer); ok {
15 1
		return []byte(s.String()), nil
16
	}
17
18 1
	return nil, ErrUnserializableData
19
}
20