| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\Serializer\Exception; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
class NotNormalizableValueException extends UnexpectedValueException |
| 18 |
{ |
| 19 |
private ?string $currentType = null; |
| 20 |
private ?array $expectedTypes = null; |
| 21 |
private ?string $path = null; |
| 22 |
private bool $useMessageForUser = false; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null, ?string $currentType = null, ?array $expectedTypes = null, ?string $path = null, bool $useMessageForUser = false) |
| 28 |
{ |
| 29 |
parent::__construct($message, $code, $previous); |
| 30 |
|
| 31 |
$this->currentType = $currentType; |
| 32 |
$this->expectedTypes = $expectedTypes ? array_map(strval(...), $expectedTypes) : $expectedTypes; |
| 33 |
$this->path = $path; |
| 34 |
$this->useMessageForUser = $useMessageForUser; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public static function createForUnexpectedDataType(string $message, mixed $data, array $expectedTypes, ?string $path = null, bool $useMessageForUser = false, int $code = 0, ?\Throwable $previous = null): self |
| 44 |
{ |
| 45 |
return new self($message, $code, $previous, get_debug_type($data), $expectedTypes, $path, $useMessageForUser); |
| 46 |
} |
| 47 |
|
| 48 |
public function getCurrentType(): ?string |
| 49 |
{ |
| 50 |
return $this->currentType; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public function getExpectedTypes(): ?array |
| 57 |
{ |
| 58 |
return $this->expectedTypes; |
| 59 |
} |
| 60 |
|
| 61 |
public function getPath(): ?string |
| 62 |
{ |
| 63 |
return $this->path; |
| 64 |
} |
| 65 |
|
| 66 |
public function canUseMessageForUser(): ?bool |
| 67 |
{ |
| 68 |
return $this->useMessageForUser; |
| 69 |
} |
| 70 |
} |