| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
namespace Carbon\Exceptions; |
| 15 |
|
| 16 |
use InvalidArgumentException as BaseInvalidArgumentException; |
| 17 |
use Throwable; |
| 18 |
|
| 19 |
class ParseErrorException extends BaseInvalidArgumentException implements InvalidArgumentException |
| 20 |
{ |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
protected $expected; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
protected $actual; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
protected $help; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public function __construct($expected, $actual, $help = '', $code = 0, ?Throwable $previous = null) |
| 51 |
{ |
| 52 |
$this->expected = $expected; |
| 53 |
$this->actual = $actual; |
| 54 |
$this->help = $help; |
| 55 |
|
| 56 |
$actual = $actual === '' ? 'data is missing' : "get '$actual'"; |
| 57 |
|
| 58 |
parent::__construct(trim("Format expected $expected but $actual\n$help"), $code, $previous); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public function getExpected(): string |
| 67 |
{ |
| 68 |
return $this->expected; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public function getActual(): string |
| 77 |
{ |
| 78 |
return $this->actual; |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
public function getHelp(): string |
| 87 |
{ |
| 88 |
return $this->help; |
| 89 |
} |
| 90 |
} |