Passed
Push — caching ( 6c9b2f...fd9061 )
by Nate
03:03
created

TypeAdapter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 2
c 2
b 0
f 0
dl 0
loc 23
ccs 0
cts 2
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A canCache() 0 3 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Gson;
10
11
use Tebru\Gson\Context\ReaderContext;
12
use Tebru\Gson\Context\WriterContext;
13
14
/**
15
 * Class TypeAdapter
16
 *
17
 * Create custom TypeAdapters by extending this class.  This provides a low level
18
 * alternative to creating JsonSerializers or JsonDeserializers.
19
 *
20
 * @author Nate Brunette <[email protected]>
21
 */
22
abstract class TypeAdapter implements Cacheable
23
{
24
    /**
25
     * Read the next value, convert it to its type and return it
26
     *
27
     * @param mixed $value
28
     * @param ReaderContext $context
29
     * @return mixed
30
     */
31
    abstract public function read($value, ReaderContext $context);
32
33
    /**
34
     * Write the value to the writer for the type
35
     *
36
     * @param mixed $value
37
     * @param WriterContext $context
38
     * @return mixed
39
     */
40
    abstract public function write($value, WriterContext $context);
41
42
    public function canCache(): bool
43
    {
44
        return false;
45
    }
46
}
47