Debian Codegraph @

lib/3rdParty/composer/nesbot/carbon/src/Carbon/Exceptions/ParseErrorException.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 /**
6 * This file is part of the Carbon package.
7 *
8 * (c) Brian Nesbitt <[email protected]>
9 *
10 * For the full copyright and license information, please view the LICENSE
11 * file that was distributed with this source code.
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 * The expected.
23 *
24 * @var string
25 */
26 protected $expected;
27
28 /**
29 * The actual.
30 *
31 * @var string
32 */
33 protected $actual;
34
35 /**
36 * The help message.
37 *
38 * @var string
39 */
40 protected $help;
41
42 /**
43 * Constructor.
44 *
45 * @param string $expected
46 * @param string $actual
47 * @param int $code
48 * @param Throwable|null $previous
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 * Get the expected.
63 *
64 * @return string
65 */
66 public function getExpected(): string
67 {
68 return $this->expected;
69 }
70
71 /**
72 * Get the actual.
73 *
74 * @return string
75 */
76 public function getActual(): string
77 {
78 return $this->actual;
79 }
80
81 /**
82 * Get the help message.
83 *
84 * @return string
85 */
86 public function getHelp(): string
87 {
88 return $this->help;
89 }
90 }