Encodable::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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\Retrofit\Annotation;
10
11
use Tebru\Retrofit\StringConverter;
12
13
/**
14
 * Abstract class that adds an 'encoded' boolean key to annotations to
15
 * represent data that is already encoded or not.
16
 *
17
 * @author Nate Brunette <[email protected]>
18
 */
19
abstract class Encodable extends ParameterAnnotation
20
{
21
    /**
22
     * The values are already encoded
23
     *
24
     * @var bool
25
     */
26
    private $encoded;
27
28
    /**
29
     * Initialize annotation data
30
     */
31 18
    protected function init(): void
32
    {
33 18
        parent::init();
34
35 18
        $this->encoded = $this->data['encoded'] ?? false;
36 18
    }
37
38
    /**
39
     * Returns true if the values are already encoded
40
     *
41
     * @return bool
42
     */
43 11
    public function isEncoded(): bool
44
    {
45 11
        return $this->encoded;
46
    }
47
48
    /**
49
     * Return the converter interface class
50
     *
51
     * Can be one of RequestBodyConverter, ResponseBodyConverter, or StringConverter
52
     *
53
     * @return string
54
     */
55 6
    public function converterType(): ?string
56
    {
57 6
        return StringConverter::class;
58
    }
59
}
60