Initial commit

This commit is contained in:
2025-08-04 16:33:07 +03:30
commit f798e8e35c
9595 changed files with 1208683 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* 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 Throwable;
class BadComparisonUnitException extends UnitException
{
/**
* The unit.
*
* @var string
*/
protected $unit;
/**
* Constructor.
*
* @param string $unit
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($unit, $code = 0, ?Throwable $previous = null)
{
$this->unit = $unit;
parent::__construct("Bad comparison unit: '$unit'", $code, $previous);
}
/**
* Get the unit.
*
* @return string
*/
public function getUnit(): string
{
return $this->unit;
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* 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 BadMethodCallException as BaseBadMethodCallException;
use Throwable;
class BadFluentConstructorException extends BaseBadMethodCallException implements BadMethodCallException
{
/**
* The method.
*
* @var string
*/
protected $method;
/**
* Constructor.
*
* @param string $method
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($method, $code = 0, ?Throwable $previous = null)
{
$this->method = $method;
parent::__construct(\sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous);
}
/**
* Get the method.
*
* @return string
*/
public function getMethod(): string
{
return $this->method;
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* 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 BadMethodCallException as BaseBadMethodCallException;
use Throwable;
class BadFluentSetterException extends BaseBadMethodCallException implements BadMethodCallException
{
/**
* The setter.
*
* @var string
*/
protected $setter;
/**
* Constructor.
*
* @param string $setter
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($setter, $code = 0, ?Throwable $previous = null)
{
$this->setter = $setter;
parent::__construct(\sprintf("Unknown fluent setter '%s'", $setter), $code, $previous);
}
/**
* Get the setter.
*
* @return string
*/
public function getSetter(): string
{
return $this->setter;
}
}

View File

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
/**
* 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;
interface BadMethodCallException extends Exception
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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 RuntimeException as BaseRuntimeException;
final class EndLessPeriodException extends BaseRuntimeException implements RuntimeException
{
//
}

View File

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
/**
* 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;
interface Exception
{
//
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* 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 RuntimeException as BaseRuntimeException;
use Throwable;
class ImmutableException extends BaseRuntimeException implements RuntimeException
{
/**
* The value.
*
* @var string
*/
protected $value;
/**
* Constructor.
*
* @param string $value the immutable type/value
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($value, $code = 0, ?Throwable $previous = null)
{
$this->value = $value;
parent::__construct("$value is immutable.", $code, $previous);
}
/**
* Get the value.
*
* @return string
*/
public function getValue(): string
{
return $this->value;
}
}

View File

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
/**
* 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;
interface InvalidArgumentException extends Exception
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class InvalidCastException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/**
* 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;
use Throwable;
class InvalidDateException extends BaseInvalidArgumentException implements InvalidArgumentException
{
/**
* The invalid field.
*
* @var string
*/
private $field;
/**
* The invalid value.
*
* @var mixed
*/
private $value;
/**
* Constructor.
*
* @param string $field
* @param mixed $value
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($field, $value, $code = 0, ?Throwable $previous = null)
{
$this->field = $field;
$this->value = $value;
parent::__construct($field.' : '.$value.' is not a valid value.', $code, $previous);
}
/**
* Get the invalid field.
*
* @return string
*/
public function getField()
{
return $this->field;
}
/**
* Get the invalid value.
*
* @return mixed
*/
public function getValue()
{
return $this->value;
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class InvalidFormatException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class InvalidIntervalException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class InvalidPeriodDateException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class InvalidPeriodParameterException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class InvalidTimeZoneException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class InvalidTypeException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/**
* 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 Carbon\CarbonInterface;
use InvalidArgumentException as BaseInvalidArgumentException;
use Throwable;
class NotACarbonClassException extends BaseInvalidArgumentException implements InvalidArgumentException
{
/**
* The className.
*
* @var string
*/
protected $className;
/**
* Constructor.
*
* @param string $className
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($className, $code = 0, ?Throwable $previous = null)
{
$this->className = $className;
parent::__construct(\sprintf(
'Given class does not implement %s: %s',
CarbonInterface::class,
$className,
), $code, $previous);
}
/**
* Get the className.
*
* @return string
*/
public function getClassName(): string
{
return $this->className;
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class NotAPeriodException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* 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;
use Throwable;
class NotLocaleAwareException extends BaseInvalidArgumentException implements InvalidArgumentException
{
/**
* Constructor.
*
* @param mixed $object
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($object, $code = 0, ?Throwable $previous = null)
{
$dump = \is_object($object) ? \get_class($object) : \gettype($object);
parent::__construct("$dump does neither implements Symfony\Contracts\Translation\LocaleAwareInterface nor getLocale() method.", $code, $previous);
}
}

View File

@@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
/**
* 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;
use Throwable;
// This will extends OutOfRangeException instead of InvalidArgumentException since 3.0.0
// use OutOfRangeException as BaseOutOfRangeException;
class OutOfRangeException extends BaseInvalidArgumentException implements InvalidArgumentException
{
/**
* The unit or name of the value.
*
* @var string
*/
private $unit;
/**
* The range minimum.
*
* @var mixed
*/
private $min;
/**
* The range maximum.
*
* @var mixed
*/
private $max;
/**
* The invalid value.
*
* @var mixed
*/
private $value;
/**
* Constructor.
*
* @param string $unit
* @param mixed $min
* @param mixed $max
* @param mixed $value
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($unit, $min, $max, $value, $code = 0, ?Throwable $previous = null)
{
$this->unit = $unit;
$this->min = $min;
$this->max = $max;
$this->value = $value;
parent::__construct("$unit must be between $min and $max, $value given", $code, $previous);
}
/**
* @return mixed
*/
public function getMax()
{
return $this->max;
}
/**
* @return mixed
*/
public function getMin()
{
return $this->min;
}
/**
* @return mixed
*/
public function getUnit()
{
return $this->unit;
}
/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}
}

View File

@@ -0,0 +1,90 @@
<?php
declare(strict_types=1);
/**
* 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;
use Throwable;
class ParseErrorException extends BaseInvalidArgumentException implements InvalidArgumentException
{
/**
* The expected.
*
* @var string
*/
protected $expected;
/**
* The actual.
*
* @var string
*/
protected $actual;
/**
* The help message.
*
* @var string
*/
protected $help;
/**
* Constructor.
*
* @param string $expected
* @param string $actual
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($expected, $actual, $help = '', $code = 0, ?Throwable $previous = null)
{
$this->expected = $expected;
$this->actual = $actual;
$this->help = $help;
$actual = $actual === '' ? 'data is missing' : "get '$actual'";
parent::__construct(trim("Format expected $expected but $actual\n$help"), $code, $previous);
}
/**
* 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;
}
}

View File

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
/**
* 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;
interface RuntimeException extends Exception
{
//
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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;
class UnitException extends BaseInvalidArgumentException implements InvalidArgumentException
{
//
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* 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 Throwable;
class UnitNotConfiguredException extends UnitException
{
/**
* The unit.
*
* @var string
*/
protected $unit;
/**
* Constructor.
*
* @param string $unit
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($unit, $code = 0, ?Throwable $previous = null)
{
$this->unit = $unit;
parent::__construct("Unit $unit have no configuration to get total from other units.", $code, $previous);
}
/**
* Get the unit.
*
* @return string
*/
public function getUnit(): string
{
return $this->unit;
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* 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;
use Throwable;
class UnknownGetterException extends BaseInvalidArgumentException implements InvalidArgumentException
{
/**
* The getter.
*
* @var string
*/
protected $getter;
/**
* Constructor.
*
* @param string $getter getter name
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($getter, $code = 0, ?Throwable $previous = null)
{
$this->getter = $getter;
parent::__construct("Unknown getter '$getter'", $code, $previous);
}
/**
* Get the getter.
*
* @return string
*/
public function getGetter(): string
{
return $this->getter;
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* 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 BadMethodCallException as BaseBadMethodCallException;
use Throwable;
class UnknownMethodException extends BaseBadMethodCallException implements BadMethodCallException
{
/**
* The method.
*
* @var string
*/
protected $method;
/**
* Constructor.
*
* @param string $method
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($method, $code = 0, ?Throwable $previous = null)
{
$this->method = $method;
parent::__construct("Method $method does not exist.", $code, $previous);
}
/**
* Get the method.
*
* @return string
*/
public function getMethod(): string
{
return $this->method;
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* 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;
use Throwable;
class UnknownSetterException extends BaseInvalidArgumentException implements BadMethodCallException
{
/**
* The setter.
*
* @var string
*/
protected $setter;
/**
* Constructor.
*
* @param string $setter setter name
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($setter, $code = 0, ?Throwable $previous = null)
{
$this->setter = $setter;
parent::__construct("Unknown setter '$setter'", $code, $previous);
}
/**
* Get the setter.
*
* @return string
*/
public function getSetter(): string
{
return $this->setter;
}
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* 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 Throwable;
class UnknownUnitException extends UnitException
{
/**
* The unit.
*
* @var string
*/
protected $unit;
/**
* Constructor.
*
* @param string $unit
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($unit, $code = 0, ?Throwable $previous = null)
{
$this->unit = $unit;
parent::__construct("Unknown unit '$unit'.", $code, $previous);
}
/**
* Get the unit.
*
* @return string
*/
public function getUnit(): string
{
return $this->unit;
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* 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 RuntimeException as BaseRuntimeException;
class UnreachableException extends BaseRuntimeException implements RuntimeException
{
//
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* 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 Exception;
/**
* @codeCoverageIgnore
*/
class UnsupportedUnitException extends UnitException
{
public function __construct(string $unit, int $code = 0, ?Exception $previous = null)
{
parent::__construct("Unsupported unit '$unit'", $code, $previous);
}
}