Passed
Pull Request — master (#47)
by Anatoly
05:00
created

FormData::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 0
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Nekhay <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Nekhay
8
 * @license https://github.com/sunrise-php/http-client-curl/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-client-curl
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sunrise\Http\Client\Curl;
15
16
use Psr\Http\Message\StreamInterface;
17
use Sunrise\Http\Message\Exception\RuntimeException;
18
19
/**
20
 * @since 2.2.0
21
 */
22
final class FormData implements StreamInterface
23
{
24
    public function __construct(
25
        /** @var array<array-key, mixed> */
26
        public readonly array $data,
27
    ) {
28
    }
29
30
    public function __toString(): string
31
    {
32
        return '';
33
    }
34
35
    public function close(): void
36
    {
37
    }
38
39
    public function detach(): mixed
40
    {
41
        return null;
42
    }
43
44
    public function getSize(): ?int
45
    {
46
        return null;
47
    }
48
49
    public function tell(): int
50
    {
51
        throw new RuntimeException('Stream does not support the tell operation');
52
    }
53
54
    public function eof(): bool
55
    {
56
        return true;
57
    }
58
59
    public function isSeekable(): bool
60
    {
61
        return false;
62
    }
63
64
    public function seek(int $offset, int $whence = SEEK_SET): void
65
    {
66
        throw new RuntimeException('Stream is not seekable');
67
    }
68
69
    public function rewind(): void
70
    {
71
        throw new RuntimeException('Stream is not seekable');
72
    }
73
74
    public function isWritable(): bool
75
    {
76
        return false;
77
    }
78
79
    public function write(string $string): int
80
    {
81
        throw new RuntimeException('Stream is not writable');
82
    }
83
84
    public function isReadable(): bool
85
    {
86
        return false;
87
    }
88
89
    public function read(int $length): string
90
    {
91
        throw new RuntimeException('Stream is not readable');
92
    }
93
94
    public function getContents(): string
95
    {
96
        throw new RuntimeException('Stream is not readable');
97
    }
98
99
    public function getMetadata(?string $key = null): mixed
100
    {
101
        return $key === null ? [] : null;
102
    }
103
}
104