MultipartBody   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 70
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getName() 0 4 1
A getContents() 0 4 1
A getHeaders() 0 4 1
A getFilename() 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\Http;
10
11
use Psr\Http\Message\StreamInterface;
12
13
use function GuzzleHttp\Psr7\stream_for;
14
15
/**
16
 * Class MultipartBody
17
 *
18
 * @author Nate Brunette <[email protected]>
19
 */
20
final class MultipartBody
21
{
22
    /**
23
     * @var string
24
     */
25
    private $name;
26
27
    /**
28
     * @var StreamInterface
29
     */
30
    private $contents;
31
32
    /**
33
     * @var array
34
     */
35
    private $headers;
36
37
    /**
38
     * @var string
39
     */
40
    private $filename;
41
42
    /**
43
     * Constructor
44
     *
45
     * @param string $name
46
     * @param mixed $contents
47
     * @param array[] $headers
48
     * @param null|string $filename
49
     */
50 5
    public function __construct(string $name, $contents, array $headers = [], ?string $filename = null)
51
    {
52 5
        $this->name = $name;
53 5
        $this->contents = stream_for($contents);
54 5
        $this->headers = $headers;
55 5
        $this->filename = $filename;
56 5
    }
57
58
    /**
59
     * @return string
60
     */
61 5
    public function getName(): string
62
    {
63 5
        return $this->name;
64
    }
65
66
    /**
67
     * @return StreamInterface
68
     */
69 5
    public function getContents(): StreamInterface
70
    {
71 5
        return $this->contents;
72
    }
73
74
    /**
75
     * @return array
76
     */
77 5
    public function getHeaders(): array
78
    {
79 5
        return $this->headers;
80
    }
81
82
    /**
83
     * @return string|null
84
     */
85 5
    public function getFilename(): ?string
86
    {
87 5
        return $this->filename;
88
    }
89
}
90