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

valkyrjaio / valkyrja / 16015663376

02 Jul 2025 03:52AM UTC coverage: 38.284% (-5.8%) from 44.066%
16015663376

push

github

web-flow
Merge pull request #38 from valkyrjaio/config-update

Config update

156 of 338 new or added lines in 42 files covered. (46.15%)

679 existing lines in 118 files now uncovered.

4122 of 10767 relevant lines covered (38.28%)

9.53 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
            if (! $valkyrjaUploadedFile instanceof ValkyrjaUploadedFile) {
4✔
UNCOV
110
                throw new RuntimeException('Invalid uploaded file');
×
111
            }
112

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

116
        return $uploadedFiles;
6✔
117
    }
118

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

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

133
        return $new;
2✔
134
    }
135

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

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

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

157
        return $new;
2✔
158
    }
159

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

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

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

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

187
        return $new;
2✔
188
    }
189

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

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

199
        return $new;
2✔
200
    }
201
}
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