6ae6b431e547a72d1f32351415263a70cd3716c6
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 /**
4 * @see https://github.com/laminas/laminas-diactoros for the canonical source repository
5 * @copyright https://github.com/laminas/laminas-diactoros/blob/master/COPYRIGHT.md
6 * @license https://github.com/laminas/laminas-diactoros/blob/master/LICENSE.md New BSD License
7 */
8
9 declare(strict_types=1);
10
11 namespace Laminas\Diactoros\Exception;
12
13 use Throwable;
14 use UnexpectedValueException;
15
16 class DeserializationException extends UnexpectedValueException implements ExceptionInterface
17 {
18 public static function forInvalidHeader() : self
19 {
20 throw new self('Invalid header detected');
21 }
22
23 public static function forInvalidHeaderContinuation() : self
24 {
25 throw new self('Invalid header continuation');
26 }
27
28 public static function forRequestFromArray(Throwable $previous) : self
29 {
30 return new self('Cannot deserialize request', $previous->getCode(), $previous);
31 }
32
33 public static function forResponseFromArray(Throwable $previous) : self
34 {
35 return new self('Cannot deserialize response', $previous->getCode(), $previous);
36 }
37
38 public static function forUnexpectedCarriageReturn() : self
39 {
40 throw new self('Unexpected carriage return detected');
41 }
42
43 public static function forUnexpectedEndOfHeaders() : self
44 {
45 throw new self('Unexpected end of headers');
46 }
47
48 public static function forUnexpectedLineFeed() : self
49 {
50 throw new self('Unexpected line feed detected');
51 }
52 }