Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 150 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 150 Revision 399
Zeile 7... Zeile 7...
7
use Illuminate\Support\Traits\Macroable;
7
use Illuminate\Support\Traits\Macroable;
8
use LogicException;
8
use LogicException;
Zeile 9... Zeile 9...
9
 
9
 
10
class Response implements ArrayAccess
10
class Response implements ArrayAccess
11
{
11
{
12
    use Macroable {
12
    use Concerns\DeterminesStatusCode, Macroable {
13
        __call as macroCall;
13
        __call as macroCall;
Zeile 14... Zeile 14...
14
    }
14
    }
15
 
15
 
Zeile 163... Zeile 163...
163
    {
163
    {
164
        return $this->status() >= 200 && $this->status() < 300;
164
        return $this->status() >= 200 && $this->status() < 300;
165
    }
165
    }
Zeile 166... Zeile 166...
166
 
166
 
167
    /**
-
 
168
     * Determine if the response code was "OK".
-
 
169
     *
-
 
170
     * @return bool
-
 
171
     */
-
 
172
    public function ok()
-
 
173
    {
-
 
174
        return $this->status() === 200;
-
 
175
    }
-
 
176
 
-
 
177
    /**
167
    /**
178
     * Determine if the response was a redirect.
168
     * Determine if the response was a redirect.
179
     *
169
     *
180
     * @return bool
170
     * @return bool
181
     */
171
     */
182
    public function redirect()
172
    public function redirect()
183
    {
173
    {
184
        return $this->status() >= 300 && $this->status() < 400;
174
        return $this->status() >= 300 && $this->status() < 400;
Zeile 185... Zeile 175...
185
    }
175
    }
186
 
-
 
187
    /**
-
 
188
     * Determine if the response was a 401 "Unauthorized" response.
-
 
189
     *
-
 
190
     * @return bool
-
 
191
     */
-
 
192
    public function unauthorized()
-
 
193
    {
-
 
194
        return $this->status() === 401;
-
 
195
    }
-
 
196
 
-
 
197
    /**
-
 
198
     * Determine if the response was a 403 "Forbidden" response.
-
 
199
     *
-
 
200
     * @return bool
-
 
201
     */
-
 
202
    public function forbidden()
-
 
203
    {
-
 
204
        return $this->status() === 403;
-
 
205
    }
-
 
206
 
-
 
207
    /**
-
 
208
     * Determine if the response was a 404 "Not Found" response.
-
 
209
     *
-
 
210
     * @return bool
-
 
211
     */
-
 
212
    public function notFound()
-
 
213
    {
-
 
214
        return $this->status() === 404;
-
 
215
    }
-
 
216
 
176
 
217
    /**
177
    /**
218
     * Determine if the response indicates a client or server error occurred.
178
     * Determine if the response indicates a client or server error occurred.
219
     *
179
     *
220
     * @return bool
180
     * @return bool
Zeile 349... Zeile 309...
349
    {
309
    {
350
        return value($condition, $this) ? $this->throw(func_get_args()[1] ?? null) : $this;
310
        return value($condition, $this) ? $this->throw(func_get_args()[1] ?? null) : $this;
351
    }
311
    }
Zeile 352... Zeile 312...
352
 
312
 
-
 
313
    /**
-
 
314
     * Throw an exception if the response status code matches the given code.
-
 
315
     *
-
 
316
     * @param  callable|int  $statusCode
-
 
317
     * @return $this
-
 
318
     *
-
 
319
     * @throws \Illuminate\Http\Client\RequestException
-
 
320
     */
-
 
321
    public function throwIfStatus($statusCode)
-
 
322
    {
-
 
323
        if (is_callable($statusCode) &&
-
 
324
            $statusCode($this->status(), $this)) {
-
 
325
            return $this->throw();
-
 
326
        }
-
 
327
 
-
 
328
        return $this->status() === $statusCode ? $this->throw() : $this;
-
 
329
    }
-
 
330
 
-
 
331
    /**
-
 
332
     * Throw an exception unless the response status code matches the given code.
-
 
333
     *
-
 
334
     * @param  callable|int  $statusCode
-
 
335
     * @return $this
-
 
336
     *
-
 
337
     * @throws \Illuminate\Http\Client\RequestException
-
 
338
     */
-
 
339
    public function throwUnlessStatus($statusCode)
-
 
340
    {
-
 
341
        if (is_callable($statusCode) &&
-
 
342
            ! $statusCode($this->status(), $this)) {
-
 
343
            return $this->throw();
-
 
344
        }
-
 
345
 
-
 
346
        return $this->status() === $statusCode ? $this : $this->throw();
-
 
347
    }
-
 
348
 
-
 
349
    /**
-
 
350
     * Throw an exception if the response status code is a 4xx level code.
-
 
351
     *
-
 
352
     * @return $this
-
 
353
     *
-
 
354
     * @throws \Illuminate\Http\Client\RequestException
-
 
355
     */
-
 
356
    public function throwIfClientError()
-
 
357
    {
-
 
358
        return $this->clientError() ? $this->throw() : $this;
-
 
359
    }
-
 
360
 
-
 
361
    /**
-
 
362
     * Throw an exception if the response status code is a 5xx level code.
-
 
363
     *
-
 
364
     * @return $this
-
 
365
     *
-
 
366
     * @throws \Illuminate\Http\Client\RequestException
-
 
367
     */
-
 
368
    public function throwIfServerError()
-
 
369
    {
-
 
370
        return $this->serverError() ? $this->throw() : $this;
-
 
371
    }
-
 
372
 
353
    /**
373
    /**
354
     * Determine if the given offset exists.
374
     * Determine if the given offset exists.
355
     *
375
     *
356
     * @param  string  $offset
376
     * @param  string  $offset
357
     * @return bool
377
     * @return bool