Completed
Pull Request — master (#72)
by Nate
03:35
created

MultipartBody::getContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
    public function __construct(string $name, $contents, array $headers = [], ?string $filename = null)
51
    {
52
        $this->name = $name;
53
        $this->contents = stream_for($contents);
54
        $this->headers = $headers;
55
        $this->filename = $filename;
56
    }
57
58
    /**
59
     * @return string|null
60
     */
61
    public function getName(): ?string
62
    {
63
        return $this->name;
64
    }
65
66
    /**
67
     * @return StreamInterface|null
68
     */
69
    public function getContents(): ?StreamInterface
70
    {
71
        return $this->contents;
72
    }
73
74
    /**
75
     * @return array
76
     */
77
    public function getHeaders(): array
78
    {
79
        return $this->headers;
80
    }
81
82
    /**
83
     * @return string|null
84
     */
85
    public function getFilename(): ?string
86
    {
87
        return $this->filename;
88
    }
89
}
90