Files
apimacro/vendor/nesbot/carbon/src/Carbon/Exceptions/ParseErrorException.php

89 lines
1.7 KiB
PHP
Raw Normal View History

2024-05-07 12:17:25 +02:00
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Exceptions;
use InvalidArgumentException as BaseInvalidArgumentException;
2024-05-17 12:24:19 +00:00
use Throwable;
2024-05-07 12:17:25 +02:00
class ParseErrorException extends BaseInvalidArgumentException implements InvalidArgumentException
{
2024-05-17 12:24:19 +00:00
/**
* The expected.
*
* @var string
*/
protected $expected;
/**
* The actual.
*
* @var string
*/
protected $actual;
/**
* The help message.
*
* @var string
*/
protected $help;
2024-05-07 12:17:25 +02:00
/**
* Constructor.
*
* @param string $expected
* @param string $actual
* @param int $code
2024-05-17 12:24:19 +00:00
* @param Throwable|null $previous
2024-05-07 12:17:25 +02:00
*/
2024-05-17 12:24:19 +00:00
public function __construct($expected, $actual, $help = '', $code = 0, Throwable $previous = null)
2024-05-07 12:17:25 +02:00
{
2024-05-17 12:24:19 +00:00
$this->expected = $expected;
$this->actual = $actual;
$this->help = $help;
2024-05-07 12:17:25 +02:00
$actual = $actual === '' ? 'data is missing' : "get '$actual'";
parent::__construct(trim("Format expected $expected but $actual\n$help"), $code, $previous);
}
2024-05-17 12:24:19 +00:00
/**
* Get the expected.
*
* @return string
*/
public function getExpected(): string
{
return $this->expected;
}
/**
* Get the actual.
*
* @return string
*/
public function getActual(): string
{
return $this->actual;
}
/**
* Get the help message.
*
* @return string
*/
public function getHelp(): string
{
return $this->help;
}
2024-05-07 12:17:25 +02:00
}