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

codeigniter4 / CodeIgniter4 / 8677009716

13 Apr 2024 11:45PM UTC coverage: 84.44% (-2.2%) from 86.607%
8677009716

push

github

web-flow
Merge pull request #8776 from kenjis/fix-findQualifiedNameFromPath-Cannot-declare-class-v3

fix: Cannot declare class CodeIgniter\Config\Services, because the name is already in use

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

478 existing lines in 72 files now uncovered.

20318 of 24062 relevant lines covered (84.44%)

188.23 hits per line

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

85.71
/system/HTTP/Exceptions/HTTPException.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\HTTP\Exceptions;
15

16
use CodeIgniter\Exceptions\FrameworkException;
17

18
/**
19
 * Things that can go wrong with HTTP
20
 */
21
class HTTPException extends FrameworkException
22
{
23
    /**
24
     * For CurlRequest
25
     *
26
     * @return HTTPException
27
     *
28
     * @codeCoverageIgnore
29
     */
30
    public static function forMissingCurl()
31
    {
UNCOV
32
        return new static(lang('HTTP.missingCurl'));
×
33
    }
34

35
    /**
36
     * For CurlRequest
37
     *
38
     * @return HTTPException
39
     */
40
    public static function forSSLCertNotFound(string $cert)
41
    {
42
        return new static(lang('HTTP.sslCertNotFound', [$cert]));
2✔
43
    }
44

45
    /**
46
     * For CurlRequest
47
     *
48
     * @return HTTPException
49
     */
50
    public static function forInvalidSSLKey(string $key)
51
    {
52
        return new static(lang('HTTP.invalidSSLKey', [$key]));
2✔
53
    }
54

55
    /**
56
     * For CurlRequest
57
     *
58
     * @return HTTPException
59
     *
60
     * @codeCoverageIgnore
61
     */
62
    public static function forCurlError(string $errorNum, string $error)
63
    {
UNCOV
64
        return new static(lang('HTTP.curlError', [$errorNum, $error]));
×
65
    }
66

67
    /**
68
     * For IncomingRequest
69
     *
70
     * @return HTTPException
71
     */
72
    public static function forInvalidNegotiationType(string $type)
73
    {
74
        return new static(lang('HTTP.invalidNegotiationType', [$type]));
1✔
75
    }
76

77
    /**
78
     * Thrown in IncomingRequest when the json_decode() produces
79
     *  an error code other than JSON_ERROR_NONE.
80
     *
81
     * @param string $error The error message
82
     *
83
     * @return static
84
     */
85
    public static function forInvalidJSON(?string $error = null)
86
    {
87
        return new static(lang('HTTP.invalidJSON', [$error]));
3✔
88
    }
89

90
    /**
91
     * For Message
92
     *
93
     * @return HTTPException
94
     */
95
    public static function forInvalidHTTPProtocol(string $invalidVersion)
96
    {
97
        return new static(lang('HTTP.invalidHTTPProtocol', [$invalidVersion]));
1✔
98
    }
99

100
    /**
101
     * For Negotiate
102
     *
103
     * @return HTTPException
104
     */
105
    public static function forEmptySupportedNegotiations()
106
    {
107
        return new static(lang('HTTP.emptySupportedNegotiations'));
1✔
108
    }
109

110
    /**
111
     * For RedirectResponse
112
     *
113
     * @return HTTPException
114
     */
115
    public static function forInvalidRedirectRoute(string $route)
116
    {
117
        return new static(lang('HTTP.invalidRoute', [$route]));
2✔
118
    }
119

120
    /**
121
     * For Response
122
     *
123
     * @return HTTPException
124
     */
125
    public static function forMissingResponseStatus()
126
    {
127
        return new static(lang('HTTP.missingResponseStatus'));
1✔
128
    }
129

130
    /**
131
     * For Response
132
     *
133
     * @return HTTPException
134
     */
135
    public static function forInvalidStatusCode(int $code)
136
    {
137
        return new static(lang('HTTP.invalidStatusCode', [$code]));
3✔
138
    }
139

140
    /**
141
     * For Response
142
     *
143
     * @return HTTPException
144
     */
145
    public static function forUnkownStatusCode(int $code)
146
    {
147
        return new static(lang('HTTP.unknownStatusCode', [$code]));
1✔
148
    }
149

150
    /**
151
     * For URI
152
     *
153
     * @return HTTPException
154
     */
155
    public static function forUnableToParseURI(string $uri)
156
    {
157
        return new static(lang('HTTP.cannotParseURI', [$uri]));
3✔
158
    }
159

160
    /**
161
     * For URI
162
     *
163
     * @return HTTPException
164
     */
165
    public static function forURISegmentOutOfRange(int $segment)
166
    {
167
        return new static(lang('HTTP.segmentOutOfRange', [$segment]));
9✔
168
    }
169

170
    /**
171
     * For URI
172
     *
173
     * @return HTTPException
174
     */
175
    public static function forInvalidPort(int $port)
176
    {
177
        return new static(lang('HTTP.invalidPort', [$port]));
3✔
178
    }
179

180
    /**
181
     * For URI
182
     *
183
     * @return HTTPException
184
     */
185
    public static function forMalformedQueryString()
186
    {
187
        return new static(lang('HTTP.malformedQueryString'));
1✔
188
    }
189

190
    /**
191
     * For Uploaded file move
192
     *
193
     * @return HTTPException
194
     */
195
    public static function forAlreadyMoved()
196
    {
197
        return new static(lang('HTTP.alreadyMoved'));
1✔
198
    }
199

200
    /**
201
     * For Uploaded file move
202
     *
203
     * @return HTTPException
204
     */
205
    public static function forInvalidFile(?string $path = null)
206
    {
207
        return new static(lang('HTTP.invalidFile'));
1✔
208
    }
209

210
    /**
211
     * For Uploaded file move
212
     *
213
     * @return HTTPException
214
     */
215
    public static function forMoveFailed(string $source, string $target, string $error)
216
    {
217
        return new static(lang('HTTP.moveFailed', [$source, $target, $error]));
2✔
218
    }
219

220
    /**
221
     * For Invalid SameSite attribute setting
222
     *
223
     * @return HTTPException
224
     *
225
     * @deprecated Use `CookieException::forInvalidSameSite()` instead.
226
     *
227
     * @codeCoverageIgnore
228
     */
229
    public static function forInvalidSameSiteSetting(string $samesite)
230
    {
UNCOV
231
        return new static(lang('Security.invalidSameSiteSetting', [$samesite]));
×
232
    }
233

234
    /**
235
     * Thrown when the JSON format is not supported.
236
     * This is specifically for cases where data validation is expected to work with key-value structures.
237
     *
238
     * @return HTTPException
239
     */
240
    public static function forUnsupportedJSONFormat()
241
    {
242
        return new static(lang('HTTP.unsupportedJSONFormat'));
2✔
243
    }
244
}
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

© 2025 Coveralls, Inc