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

nette / application / 27919019709

21 Jun 2026 10:08PM UTC coverage: 84.111% (+0.05%) from 84.059%
27919019709

push

github

dg
phpstan fix

2038 of 2423 relevant lines covered (84.11%)

0.84 hits per line

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

73.53
/src/Application/Request.php
1
<?php declare(strict_types=1);
1✔
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Nette\Application;
9

10
use Nette;
11
use function func_num_args, strcasecmp;
12

13

14
/**
15
 * Presenter request.
16
 *
17
 * @property string $presenterName
18
 * @property array<string,mixed> $parameters
19
 * @property array<string,mixed> $post
20
 * @property array<string,mixed> $files
21
 * @property ?string $method
22
 */
23
final class Request
24
{
25
        use Nette\SmartObject;
26

27
        /** method */
28
        public const FORWARD = 'FORWARD';
29

30
        /** flag */
31
        public const RESTORED = 'restored';
32

33
        /** flag */
34
        public const VARYING = 'varying';
35

36

37
        public function __construct(
1✔
38
                private string $name,
39
                private ?string $method = null,
40
                /** @var array<string, mixed> */
41
                private array $params = [],
42
                /** @var array<string, mixed> */
43
                private array $post = [],
44
                /** @var array<string, mixed> */
45
                private array $files = [],
46
                /** @var array<string, bool> */
47
                private array $flags = [],
48
        ) {
49
        }
1✔
50

51

52
        /**
53
         * Sets the presenter name.
54
         */
55
        public function setPresenterName(string $name): static
56
        {
57
                $this->name = $name;
×
58
                return $this;
×
59
        }
60

61

62
        /**
63
         * Returns the presenter name.
64
         */
65
        public function getPresenterName(): string
66
        {
67
                return $this->name;
1✔
68
        }
69

70

71
        /**
72
         * Sets variables provided to the presenter.
73
         * @param  array<string, mixed>  $params
74
         */
75
        public function setParameters(array $params): static
1✔
76
        {
77
                $this->params = $params;
1✔
78
                return $this;
1✔
79
        }
80

81

82
        /**
83
         * Returns all variables provided to the presenter (usually via URL).
84
         * @return array<string, mixed>
85
         */
86
        public function getParameters(): array
87
        {
88
                return $this->params;
1✔
89
        }
90

91

92
        /**
93
         * Returns a parameter provided to the presenter.
94
         */
95
        public function getParameter(string $key): mixed
1✔
96
        {
97
                return $this->params[$key] ?? null;
1✔
98
        }
99

100

101
        /**
102
         * Sets variables provided to the presenter via POST.
103
         * @param  array<string, mixed>  $params
104
         */
105
        public function setPost(array $params): static
106
        {
107
                $this->post = $params;
×
108
                return $this;
×
109
        }
110

111

112
        /**
113
         * Returns a variable provided to the presenter via POST.
114
         * If no key is passed, returns the entire array.
115
         */
116
        public function getPost(?string $key = null): mixed
1✔
117
        {
118
                return func_num_args() === 0
1✔
119
                        ? $this->post
1✔
120
                        : ($this->post[(string) $key] ?? null);
1✔
121
        }
122

123

124
        /**
125
         * Sets all uploaded files.
126
         * @param  array<string, mixed>  $files
127
         */
128
        public function setFiles(array $files): static
129
        {
130
                $this->files = $files;
×
131
                return $this;
×
132
        }
133

134

135
        /**
136
         * Returns all uploaded files.
137
         * @return array<string, mixed>
138
         */
139
        public function getFiles(): array
140
        {
141
                return $this->files;
×
142
        }
143

144

145
        /**
146
         * Sets the method.
147
         */
148
        public function setMethod(?string $method): static
149
        {
150
                $this->method = $method;
×
151
                return $this;
×
152
        }
153

154

155
        /**
156
         * Returns the method.
157
         */
158
        public function getMethod(): ?string
159
        {
160
                return $this->method;
1✔
161
        }
162

163

164
        /**
165
         * Checks if the method is the given one.
166
         */
167
        public function isMethod(string $method): bool
1✔
168
        {
169
                return strcasecmp($this->method ?? '', $method) === 0;
1✔
170
        }
171

172

173
        /**
174
         * Sets the flag.
175
         */
176
        public function setFlag(string $flag, bool $value = true): static
1✔
177
        {
178
                $this->flags[$flag] = $value;
1✔
179
                return $this;
1✔
180
        }
181

182

183
        /**
184
         * Checks the flag.
185
         */
186
        public function hasFlag(string $flag): bool
1✔
187
        {
188
                return !empty($this->flags[$flag]);
1✔
189
        }
190

191

192
        /** @return array<string, mixed> */
193
        public function toArray(): array
194
        {
195
                $params = $this->params;
1✔
196
                $params['presenter'] = $this->name;
1✔
197
                return $params;
1✔
198
        }
199
}
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