for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PHPKitchen\Platform\Exception\Mixin;
/**
* Represent static constructors for exceptions.
*
* @property string $message exception message.
* @property int $code exception code.
* @author Dmitry Kolodko <[email protected]>
* @since 1.0
*/
trait StaticConstructors {
public static function withMessage(string $message): self {
$exception = new static();
$exception->message = $message;
return $exception;
}
public static function withCode(int $code): self {
$exception->code = $code;
public function andMessage(string $message): self {
$this->message = $message;
return $this;
public function andCode(int $code): self {
$this->code = $code;