Passed
Push — master ( cbd69a...c32edb )
by Nikita
01:43
created

decode.*Decoder.Decode   A

Complexity

Conditions 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.1406

Importance

Changes 0
Metric Value
cc 3
eloc 5
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 3.1406
rs 10
c 0
b 0
f 0
nop 1
1
package decode
2
3
import (
4
	"io"
5
	"reflect"
6
)
7
8
type Decoder struct {
9
	r io.Reader
10
}
11
12
func NewDecoder(r io.Reader) *Decoder {
13 1
	return &Decoder{r}
14
}
15
16
func (dec *Decoder) Decode(v interface{}) error {
17 1
	rv := reflect.ValueOf(v)
18 1
	if rv.Kind() != reflect.Ptr || rv.IsNil() {
19
		return &InvalidUnmarshalError{reflect.TypeOf(v)}
20
	}
21
22 1
	return decode(dec.r, v)
23
}
24