Part   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 52
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A getEncoding() 0 4 1
A allowMultiple() 0 4 1
A converterType() 0 4 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\Http\MultipartBody;
12
use Tebru\Retrofit\RequestBodyConverter;
13
14
/**
15
 * Denotes a single part of a multipart request.
16
 *
17
 * The default value represents the part name. Passing a [@see MultipartBody] will use the values from
18
 * that object, otherwise the value will be converted to a stream and added to the request.
19
 *
20
 * Use the 'encoding' key to override the default 'binary' encoding.
21
 *
22
 * @author Nate Brunette <[email protected]>
23
 *
24
 * @Annotation
25
 * @Target({"CLASS", "METHOD"})
26
 */
27
class Part extends ParameterAnnotation
28
{
29
    /**
30
     * How the multipart request is encoded
31
     *
32
     * @var string
33
     */
34
    private $encoding;
35
36
    /**
37
     * Initialize annotation data
38
     */
39 3
    protected function init(): void
40
    {
41 3
        parent::init();
42
43 3
        $this->encoding = $this->data['encoding'] ?? 'binary';
44 3
    }
45
46
    /**
47
     * Get the encoding type
48
     *
49
     * @return string
50
     */
51 2
    public function getEncoding(): string
52
    {
53 2
        return $this->encoding;
54
    }
55
56
    /**
57
     * Whether or not multiple annotations of this type can
58
     * be added to a method
59
     *
60
     * @return bool
61
     */
62 1
    public function allowMultiple(): bool
63
    {
64 1
        return true;
65
    }
66
67
    /**
68
     * Return the converter interface class
69
     *
70
     * Can be one of RequestBodyConverter, ResponseBodyConverter, or StringConverter
71
     *
72
     * @return string
73
     */
74 1
    public function converterType(): ?string
75
    {
76 1
        return RequestBodyConverter::class;
77
    }
78
}
79