diff --git a/src/Common/Exception/BadMethodCallException.php b/src/Common/Exception/BadMethodCallException.php index 7f19d96..727a101 100644 --- a/src/Common/Exception/BadMethodCallException.php +++ b/src/Common/Exception/BadMethodCallException.php @@ -5,8 +5,9 @@ namespace Atournayre\Common\Exception; use Atournayre\Contracts\Exception\ThrowableInterface; +use Atournayre\Contracts\Log\LoggableInterface; -class BadMethodCallException extends \BadMethodCallException implements ThrowableInterface +class BadMethodCallException extends \BadMethodCallException implements ThrowableInterface, LoggableInterface { - use ThrowableTrait; + use LoggableThrowableTrait; } diff --git a/src/Common/Exception/InvalidArgumentException.php b/src/Common/Exception/InvalidArgumentException.php index ab76a77..8955494 100644 --- a/src/Common/Exception/InvalidArgumentException.php +++ b/src/Common/Exception/InvalidArgumentException.php @@ -5,8 +5,9 @@ namespace Atournayre\Common\Exception; use Atournayre\Contracts\Exception\ThrowableInterface; +use Atournayre\Contracts\Log\LoggableInterface; -class InvalidArgumentException extends \InvalidArgumentException implements ThrowableInterface +class InvalidArgumentException extends \InvalidArgumentException implements ThrowableInterface, LoggableInterface { - use ThrowableTrait; + use LoggableThrowableTrait; } diff --git a/src/Common/Exception/LoggableThrowableTrait.php b/src/Common/Exception/LoggableThrowableTrait.php new file mode 100644 index 0000000..702700d --- /dev/null +++ b/src/Common/Exception/LoggableThrowableTrait.php @@ -0,0 +1,39 @@ + + */ + public function toLog(): array + { + return [ + 'message' => $this->getMessage(), + 'code' => $this->getCode(), + 'file' => $this->getFile(), + 'line' => $this->getLine(), + 'trace' => $this->getTraceAsString(), + ]; + } +} diff --git a/src/Common/Exception/MutableException.php b/src/Common/Exception/MutableException.php index 092995f..7255470 100644 --- a/src/Common/Exception/MutableException.php +++ b/src/Common/Exception/MutableException.php @@ -5,10 +5,11 @@ namespace Atournayre\Common\Exception; use Atournayre\Contracts\Exception\ThrowableInterface; +use Atournayre\Contracts\Log\LoggableInterface; -class MutableException extends \RuntimeException implements ThrowableInterface +class MutableException extends \RuntimeException implements ThrowableInterface, LoggableInterface { - use ThrowableTrait; + use LoggableThrowableTrait; public static function becauseMustBeImmutable(): self { diff --git a/src/Common/Exception/NullException.php b/src/Common/Exception/NullException.php index 6a359b0..a358928 100644 --- a/src/Common/Exception/NullException.php +++ b/src/Common/Exception/NullException.php @@ -5,10 +5,11 @@ namespace Atournayre\Common\Exception; use Atournayre\Contracts\Exception\ThrowableInterface; +use Atournayre\Contracts\Log\LoggableInterface; -class NullException extends \Exception implements ThrowableInterface +class NullException extends \Exception implements ThrowableInterface, LoggableInterface { - use ThrowableTrait; + use LoggableThrowableTrait; /** * @api diff --git a/src/Common/Exception/RuntimeException.php b/src/Common/Exception/RuntimeException.php index 61d263a..dddecf3 100644 --- a/src/Common/Exception/RuntimeException.php +++ b/src/Common/Exception/RuntimeException.php @@ -5,8 +5,9 @@ namespace Atournayre\Common\Exception; use Atournayre\Contracts\Exception\ThrowableInterface; +use Atournayre\Contracts\Log\LoggableInterface; -class RuntimeException extends \RuntimeException implements ThrowableInterface +class RuntimeException extends \RuntimeException implements ThrowableInterface, LoggableInterface { - use ThrowableTrait; + use LoggableThrowableTrait; } diff --git a/src/Common/Exception/UnexpectedValueException.php b/src/Common/Exception/UnexpectedValueException.php index 43b1162..739ba85 100644 --- a/src/Common/Exception/UnexpectedValueException.php +++ b/src/Common/Exception/UnexpectedValueException.php @@ -5,8 +5,9 @@ namespace Atournayre\Common\Exception; use Atournayre\Contracts\Exception\ThrowableInterface; +use Atournayre\Contracts\Log\LoggableInterface; -class UnexpectedValueException extends \UnexpectedValueException implements ThrowableInterface +class UnexpectedValueException extends \UnexpectedValueException implements ThrowableInterface, LoggableInterface { - use ThrowableTrait; + use LoggableThrowableTrait; } diff --git a/src/Contracts/Collection/UnshiftInterface.php b/src/Contracts/Collection/UnshiftInterface.php index 4285de9..b51af3a 100644 --- a/src/Contracts/Collection/UnshiftInterface.php +++ b/src/Contracts/Collection/UnshiftInterface.php @@ -21,5 +21,5 @@ interface UnshiftInterface * * @api */ - public function unshift(mixed $value, $key = null): self; + public function unshift(mixed $value, int|string|null $key = null): self; }