• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

valkyrjaio / valkyrja / 15659546660

15 Jun 2025 04:39AM UTC coverage: 47.202% (-0.4%) from 47.589%
15659546660

push

github

MelechMizrachi
Update Config.

5331 of 11294 relevant lines covered (47.2%)

16.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.06
/src/Valkyrja/Http/Message/Request/Psr/ServerRequest.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <melechmizrachi@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Valkyrja\Http\Message\Request\Psr;
15

16
use Psr\Http\Message\ServerRequestInterface;
17
use Psr\Http\Message\UploadedFileInterface;
18
use Valkyrja\Http\Message\Factory\UploadedFileFactory;
19
use Valkyrja\Http\Message\File\Contract\UploadedFile as ValkyrjaUploadedFile;
20
use Valkyrja\Http\Message\File\Psr\UploadedFile;
21
use Valkyrja\Http\Message\Request\Contract\ServerRequest as ValkyrjaRequest;
22
use Valkyrja\Http\Message\Request\Exception\RuntimeException;
23

24
/**
25
 * Class ServerRequest.
26
 *
27
 * @author Melech Mizrachi
28
 *
29
 * @property ValkyrjaRequest $request
30
 */
31
class ServerRequest extends Request implements ServerRequestInterface
32
{
33
    public function __construct(ValkyrjaRequest $request)
34
    {
35
        parent::__construct($request);
16✔
36
    }
37

38
    /**
39
     * @inheritDoc
40
     *
41
     * @return array<array-key, mixed>
42
     */
43
    public function getServerParams(): array
44
    {
45
        return $this->request->getServerParams();
6✔
46
    }
47

48
    /**
49
     * @inheritDoc
50
     *
51
     * @return array<array-key, mixed>
52
     */
53
    public function getCookieParams(): array
54
    {
55
        return $this->request->getCookieParams();
6✔
56
    }
57

58
    /**
59
     * @inheritDoc
60
     *
61
     * @param array<array-key, mixed> $cookies The cookies
62
     */
63
    public function withCookieParams(array $cookies): static
64
    {
65
        $new = clone $this;
2✔
66

67
        /** @var array<string, string|null> $cookies */
68
        $new->request = $this->request->withCookieParams($cookies);
2✔
69

70
        return $new;
2✔
71
    }
72

73
    /**
74
     * @inheritDoc
75
     *
76
     * @return array<array-key, mixed>
77
     */
78
    public function getQueryParams(): array
79
    {
80
        return $this->request->getQueryParams();
6✔
81
    }
82

83
    /**
84
     * @inheritDoc
85
     *
86
     * @param array<array-key, mixed> $query The query
87
     */
88
    public function withQueryParams(array $query): static
89
    {
90
        $new = clone $this;
2✔
91

92
        $new->request = $this->request->withQueryParams($query);
2✔
93

94
        return $new;
2✔
95
    }
96

97
    /**
98
     * @inheritDoc
99
     *
100
     * @return array<array-key, UploadedFile>
101
     */
102
    public function getUploadedFiles(): array
103
    {
104
        $valkyrjaUploadedFiles = $this->request->getUploadedFiles();
6✔
105

106
        $uploadedFiles = [];
6✔
107

108
        foreach ($valkyrjaUploadedFiles as $valkyrjaUploadedFile) {
6✔
109
            /** @phpstan-ignore instanceof.alwaysTrue */
110
            if (! $valkyrjaUploadedFile instanceof ValkyrjaUploadedFile) {
4✔
111
                throw new RuntimeException('Invalid uploaded file');
×
112
            }
113

114
            $uploadedFiles[] = new UploadedFile($valkyrjaUploadedFile);
4✔
115
        }
116

117
        return $uploadedFiles;
6✔
118
    }
119

120
    /**
121
     * @inheritDoc
122
     *
123
     * @param array<array-key, mixed> $uploadedFiles The uploaded files
124
     */
125
    public function withUploadedFiles(array $uploadedFiles): static
126
    {
127
        $new = clone $this;
2✔
128

129
        /** @var UploadedFileInterface[] $uploadedFiles */
130
        $new->request = $this->request->withUploadedFiles(
2✔
131
            UploadedFileFactory::fromPsrArray(...$uploadedFiles)
2✔
132
        );
2✔
133

134
        return $new;
2✔
135
    }
136

137
    /**
138
     * @inheritDoc
139
     *
140
     * @return array<array-key, mixed>|object|null
141
     */
142
    public function getParsedBody(): object|array|null
143
    {
144
        return $this->request->getParsedBody();
6✔
145
    }
146

147
    /**
148
     * @inheritDoc
149
     *
150
     * @param array<array-key, mixed>|object|null $data The data
151
     */
152
    public function withParsedBody($data): static
153
    {
154
        $new = clone $this;
2✔
155

156
        $new->request = $this->request->withParsedBody($data !== null ? (array) $data : []);
2✔
157

158
        return $new;
2✔
159
    }
160

161
    /**
162
     * @inheritDoc
163
     *
164
     * @return array<array-key, mixed>
165
     */
166
    public function getAttributes(): array
167
    {
168
        return $this->request->getAttributes();
2✔
169
    }
170

171
    /**
172
     * @inheritDoc
173
     */
174
    public function getAttribute(string $name, $default = null)
175
    {
176
        return $this->request->getAttribute($name, $default);
2✔
177
    }
178

179
    /**
180
     * @inheritDoc
181
     */
182
    public function withAttribute(string $name, $value): ServerRequestInterface
183
    {
184
        $new = clone $this;
2✔
185

186
        $new->request = $this->request->withAttribute($name, $value);
2✔
187

188
        return $new;
2✔
189
    }
190

191
    /**
192
     * @inheritDoc
193
     */
194
    public function withoutAttribute(string $name): ServerRequestInterface
195
    {
196
        $new = clone $this;
2✔
197

198
        $new->request = $this->request->withoutAttribute($name);
2✔
199

200
        return $new;
2✔
201
    }
202
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc