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

valkyrjaio / valkyrja / 16185661246

10 Jul 2025 03:48AM UTC coverage: 43.558% (-0.2%) from 43.747%
16185661246

push

github

MelechMizrachi
Http Routing: Updating ListCommand.

0 of 21 new or added lines in 1 file covered. (0.0%)

2913 existing lines in 212 files now uncovered.

3925 of 9011 relevant lines covered (43.56%)

11.07 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 Override;
17
use Psr\Http\Message\ServerRequestInterface;
18
use Psr\Http\Message\UploadedFileInterface;
19
use Valkyrja\Http\Message\Factory\UploadedFileFactory;
20
use Valkyrja\Http\Message\File\Contract\UploadedFile as ValkyrjaUploadedFile;
21
use Valkyrja\Http\Message\File\Psr\UploadedFile;
22
use Valkyrja\Http\Message\Request\Contract\ServerRequest as ValkyrjaRequest;
23
use Valkyrja\Http\Message\Request\Exception\RuntimeException;
24

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

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

50
    /**
51
     * @inheritDoc
52
     *
53
     * @return array<array-key, mixed>
54
     */
55
    #[Override]
56
    public function getCookieParams(): array
57
    {
58
        return $this->request->getCookieParams();
6✔
59
    }
60

61
    /**
62
     * @inheritDoc
63
     *
64
     * @param array<array-key, mixed> $cookies The cookies
65
     */
66
    #[Override]
67
    public function withCookieParams(array $cookies): static
68
    {
69
        $new = clone $this;
2✔
70

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

74
        return $new;
2✔
75
    }
76

77
    /**
78
     * @inheritDoc
79
     *
80
     * @return array<array-key, mixed>
81
     */
82
    #[Override]
83
    public function getQueryParams(): array
84
    {
85
        return $this->request->getQueryParams();
6✔
86
    }
87

88
    /**
89
     * @inheritDoc
90
     *
91
     * @param array<array-key, mixed> $query The query
92
     */
93
    #[Override]
94
    public function withQueryParams(array $query): static
95
    {
96
        $new = clone $this;
2✔
97

98
        $new->request = $this->request->withQueryParams($query);
2✔
99

100
        return $new;
2✔
101
    }
102

103
    /**
104
     * @inheritDoc
105
     *
106
     * @return array<array-key, UploadedFile>
107
     */
108
    #[Override]
109
    public function getUploadedFiles(): array
110
    {
111
        $valkyrjaUploadedFiles = $this->request->getUploadedFiles();
6✔
112

113
        $uploadedFiles = [];
6✔
114

115
        foreach ($valkyrjaUploadedFiles as $valkyrjaUploadedFile) {
6✔
116
            if (! $valkyrjaUploadedFile instanceof ValkyrjaUploadedFile) {
4✔
UNCOV
117
                throw new RuntimeException('Invalid uploaded file');
×
118
            }
119

120
            $uploadedFiles[] = new UploadedFile($valkyrjaUploadedFile);
4✔
121
        }
122

123
        return $uploadedFiles;
6✔
124
    }
125

126
    /**
127
     * @inheritDoc
128
     *
129
     * @param array<array-key, mixed> $uploadedFiles The uploaded files
130
     */
131
    #[Override]
132
    public function withUploadedFiles(array $uploadedFiles): static
133
    {
134
        $new = clone $this;
2✔
135

136
        /** @var UploadedFileInterface[] $uploadedFiles */
137
        $new->request = $this->request->withUploadedFiles(
2✔
138
            UploadedFileFactory::fromPsrArray(...$uploadedFiles)
2✔
139
        );
2✔
140

141
        return $new;
2✔
142
    }
143

144
    /**
145
     * @inheritDoc
146
     *
147
     * @return array<array-key, mixed>|object|null
148
     */
149
    #[Override]
150
    public function getParsedBody(): object|array|null
151
    {
152
        return $this->request->getParsedBody();
6✔
153
    }
154

155
    /**
156
     * @inheritDoc
157
     *
158
     * @param array<array-key, mixed>|object|null $data The data
159
     */
160
    #[Override]
161
    public function withParsedBody($data): static
162
    {
163
        $new = clone $this;
2✔
164

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

167
        return $new;
2✔
168
    }
169

170
    /**
171
     * @inheritDoc
172
     *
173
     * @return array<array-key, mixed>
174
     */
175
    #[Override]
176
    public function getAttributes(): array
177
    {
178
        return $this->request->getAttributes();
2✔
179
    }
180

181
    /**
182
     * @inheritDoc
183
     */
184
    #[Override]
185
    public function getAttribute(string $name, $default = null)
186
    {
187
        return $this->request->getAttribute($name, $default);
2✔
188
    }
189

190
    /**
191
     * @inheritDoc
192
     */
193
    #[Override]
194
    public function withAttribute(string $name, $value): ServerRequestInterface
195
    {
196
        $new = clone $this;
2✔
197

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

200
        return $new;
2✔
201
    }
202

203
    /**
204
     * @inheritDoc
205
     */
206
    #[Override]
207
    public function withoutAttribute(string $name): ServerRequestInterface
208
    {
209
        $new = clone $this;
2✔
210

211
        $new->request = $this->request->withoutAttribute($name);
2✔
212

213
        return $new;
2✔
214
    }
215
}
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